From: "Elijah G." <eg642616@gmail.com>
To: Po Lu <luangruo@yahoo.com>
Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: Re: Stipples support in MS-Windows port
Date: Mon, 13 May 2024 22:07:30 -0600 [thread overview]
Message-ID: <86le4dvxx9.fsf@gmail.com> (raw)
In-Reply-To: <861q661vgf.fsf@gmail.com> (Elijah G.'s message of "Sun, 12 May 2024 17:06:40 -0600")
[-- Attachment #1: Type: text/plain, Size: 885 bytes --]
I'm a bit stuck here, i could make to use the stipple bitmap, however it
doesn't uses background and foreground color from propertized string,
(and looks very weird).
The drawing works fine, but the problem is trying to get stipple bitmap,
and makes it work well.
One way that i thought for fix this is redefining bitmap stipple for
using same string fg and bg colors and bitmap width and height, but for
this i need the bitmap bits.
I found that image_create_bitmap_from_data also makes stipple bitmap
(https://git.savannah.gnu.org/cgit/emacs.git/tree/src/image.c#n601);
i tried to found bitmap bits by using stipple bitmap id but some
functions/macros are only for X11 (e.g x_bitmap_height and
x_bitmap_width).
I would be happy to read any advice or feedback.
I've attached to this email a patch for the work that i've done and some
screenshots for the final results.
Thanks.
[-- Attachment #2: stip2.png --]
[-- Type: image/png, Size: 2446 bytes --]
[-- Attachment #3: stip1.png --]
[-- Type: image/png, Size: 1045 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-WIP-Stipple-implementation-for-MS-Windows.patch --]
[-- Type: text/x-patch, Size: 2395 bytes --]
From 7e42e34fa75ef30467423b7a43c18b0ab0c93bd6 Mon Sep 17 00:00:00 2001
From: "Elias G. Perez" <eg642616@gmail.com>
Date: Fri, 10 May 2024 20:36:42 -0600
Subject: [PATCH] [WIP] Stipple implementation for MS Windows
---
src/w32term.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/src/w32term.c b/src/w32term.c
index a9aff304771..8e9ffcb8c43 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1248,6 +1248,33 @@ w32_clear_glyph_string_rect (struct glyph_string *s,
real_w, real_h);
}
+/* Fill background with bitmap S glyph, with GC, X, Y, WIDTH, HEIGHT, HDC. */
+static void
+XFillRectangle (HDC hdc, struct glyph_string *s, Emacs_GC *gc,
+ int x, int y, unsigned int width, unsigned int height)
+{
+ Emacs_Pixmap bm;
+ HBRUSH hb;
+
+ /* Only for tests */
+ /* COLORREF bg = gc->background; */
+ /* COLORREF fg = gc->foreground; */
+ /* COLORREF bits[] = { fg, bg, bg, bg, bg, bg, bg, bg, bg, bg }; */
+ /* bm = CreateBitmap(bw, bh, FRAME_DISPLAY_INFO(s->f)->n_planes, FRAME_DISPLAY_INFO(s->f)->n_cbits, pix); */
+ /* FIXME: ? */
+ bm = FRAME_DISPLAY_INFO (s->f)->bitmaps[s->face->stipple - 1].pixmap;
+ hb = CreatePatternBrush (bm);
+
+ RECT r;
+ r.left = x;
+ r.top = y;
+ r.right = x + width + 1;
+ r.bottom = y + height + 1;
+
+ FillRect (hdc, &r, hb);
+
+ DeleteObject(hb);
+}
/* Draw the background of glyph_string S. If S->background_filled_p
is non-zero don't draw it. FORCE_P non-zero means draw the
@@ -1264,16 +1291,15 @@ w32_draw_glyph_string_background (struct glyph_string *s, bool force_p)
{
int box_line_width = max (s->face->box_horizontal_line_width, 0);
-#if 0 /* TODO: stipple */
+#if 1 /* TODO: stipple */
if (s->stippled_p)
{
/* Fill background with a stipple pattern. */
- XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
- XFillRectangle (s->display, FRAME_W32_WINDOW (s->f), s->gc, s->x,
- s->y + box_line_width,
- s->background_width,
+ /* XSetFillStyle (s->display, s->gc, FillOpaqueStippled); */
+ XFillRectangle (s->hdc, s, s->gc, s->x,
+ s->y + box_line_width, s->background_width,
s->height - 2 * box_line_width);
- XSetFillStyle (s->display, s->gc, FillSolid);
+ /* XSetFillStyle (s->display, s->gc, FillSolid); */
s->background_filled_p = true;
}
else
--
2.44.0.windows.1
next prev parent reply other threads:[~2024-05-14 4:07 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. [this message]
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.
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86le4dvxx9.fsf@gmail.com \
--to=eg642616@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).