From: "Elijah G." <eg642616@gmail.com>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, luangruo@yahoo.com, emacs-devel@gnu.org
Subject: Re: Stipples support in MS-Windows port
Date: Mon, 27 May 2024 20:06:55 -0600 [thread overview]
Message-ID: <86a5kak7uo.fsf@gmail.com> (raw)
In-Reply-To: <CAP_d_8Vww4aXPRj3gWgUAbiLHMnLz_=GaJ1u3C5X_f=2ortffw@mail.gmail.com> (Yuri Khan's message of "Mon, 27 May 2024 13:20:17 +0700")
Yuri Khan <yuri.v.khan@gmail.com> writes:
> 1. you invert a RECT defined by coordinates where you draw the
> stipple, and that is most likely outside the bounds of the stipple
> bitmap;
> 2. you’re doing it on each draw of this stipple rather than once, so
> if you fix the RECT, you’ll be inverting the stipple each time so
> odd-numbered draw calls will come out okay but even-numbered draw
> calls will again be inverted.
Thanks you, at first it works, but increasing or decreasing text scale
doesn't invert the rect, I'm trying to figure how to calling it once.
Also I'm wondering if it's better invert bitmap pixels before using
_w32_create_pixmap_from_bitmap_data_
Like this:
for (int i = 0; i < (width + 7) / 8; i++)
bits[i] = (~(bits[i]));
stipple = w32_create_pixmap_from_bitmap_data (width, height, bits);
Here is the code:
--8<---------------cut here---------------start------------->8---
@@ -56,10 +56,12 @@ #define CP_DEFAULT 1004
struct w32_bitmap_record
{
Emacs_Pixmap pixmap;
char *file;
+ Emacs_Pixmap stipple;
+ bool_bf stipple_applied_p;
HINSTANCE hinst; /* Used to load the file */
int refcount;
/* Record some info about this pixmap. */
int height, width, depth;
};
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
static void
w32_fill_stipple_pattern (HDC hdc, struct glyph_string *s, Emacs_GC *gc,
int x, int y, unsigned int width, unsigned int height)
{
SetTextColor (hdc, gc->foreground);
SetBkColor (hdc, gc->background);
RECT r;
r.left = x;
r.top = y;
r.right = x + width;
r.bottom = y + height;
Emacs_Pixmap bm;
bm = FRAME_DISPLAY_INFO (s->f)->bitmaps[s->face->stipple - 1].stipple;
/* Windows mono bitmaps are reversed compared with X. */
HDC compat_dc;
if (FRAME_DISPLAY_INFO (s->f)
->bitmaps[s->face->stipple - 1]
.stipple_applied_p
!= true)
{
compat_dc = CreateCompatibleDC (hdc);
SelectObject (compat_dc, bm);
RECT r2;
r2.left = 0;
r2.top = 0;
r2.right = width;
r2.bottom = height;
InvertRect (compat_dc, &r2);
}
HBRUSH hb = CreatePatternBrush (bm);
FillRect (hdc, &r, hb);
DeleteObject (hb);
if (FRAME_DISPLAY_INFO (s->f)
->bitmaps[s->face->stipple - 1]
.stipple_applied_p
!= true)
{
DeleteDC (compat_dc);
FRAME_DISPLAY_INFO (s->f)
->bitmaps[s->face->stipple - 1]
.stipple_applied_p
= true;
}
}
--8<---------------cut here---------------end--------------->8---
next prev parent reply other threads:[~2024-05-28 2:06 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 2:53 Stipples support in MS-Windows port Elijah G
2024-05-03 6:09 ` Eli Zaretskii
2024-05-03 7:30 ` Po Lu
2024-05-05 3:43 ` Elijah G
2024-05-05 4:04 ` Po Lu
2024-05-05 4:30 ` Po Lu
2024-05-06 5:17 ` Elijah G
2024-05-11 5:10 ` Elijah G
2024-05-11 5:27 ` Po Lu
2024-05-11 8:24 ` Eli Zaretskii
2024-05-12 23:06 ` Elijah G.
2024-05-14 4:07 ` Elijah G.
2024-05-14 5:28 ` Po Lu
2024-05-15 1:43 ` Elijah G.
2024-05-19 22:37 ` Elijah G.
2024-05-20 11:15 ` Eli Zaretskii
2024-05-20 11:19 ` Po Lu
2024-05-20 12:32 ` Eli Zaretskii
2024-05-20 13:12 ` Po Lu
2024-05-20 19:44 ` Elijah G.
2024-05-21 2:00 ` Elijah G.
2024-05-21 11:49 ` Eli Zaretskii
2024-05-22 2:06 ` Elijah G.
2024-05-24 1:55 ` Elijah G.
2024-05-24 6:24 ` Po Lu
2024-05-25 7:24 ` Eli Zaretskii
2024-05-25 11:30 ` Arash Esbati
2024-05-26 2:37 ` Po Lu
2024-05-27 15:32 ` Arash Esbati
2024-05-26 0:27 ` Elijah G.
2024-05-26 8:09 ` Yuri Khan
2024-05-27 2:05 ` Elijah G.
2024-05-27 6:20 ` Yuri Khan
2024-05-28 2:06 ` Elijah G. [this message]
2024-05-26 8:51 ` Eli Zaretskii
2024-05-28 0:23 ` Elijah G.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86a5kak7uo.fsf@gmail.com \
--to=eg642616@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
--cc=yuri.v.khan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.