emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stipples support in MS-Windows port


From: Yuri Khan
Subject: Re: Stipples support in MS-Windows port
Date: Mon, 27 May 2024 13:20:17 +0700

On Mon, 27 May 2024 at 09:05, Elijah G. <eg642616@gmail.com> wrote:
>
> Yuri Khan <yuri.v.khan@gmail.com> writes:
>
> > 1. Use CreateCompatibleDC to create a memory DC.
> > 2. Select the stipple bitmap into this memory DC using SelectObject.
> > 3. Call InvertRect on that DC, passing (0, 0)–(w, h) as the target 
> > rectangle.
>
> Thank you for the advises.
> Can you explain why use (0, 0)-(w, h) instead the defined RECT from the
> code please?

RECT from the code indicates the coordinates where you’re drawing the
stipple. I’m suggesting you invert the stipple bitmap once after
creation so that it could be used without further modifications on
each draw. In this case you need to act on the stipple bitmap
coordinates.

> Here is the current function code with the advises applied (except the
> third step that i had to use a defined RECT), but it doesn't seems work
> neither, i don't know if i did something wrong when applying the steps:

Two things:

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.

> --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)
> {
…
>   RECT r;
>   r.left = x;
>   r.top = y;
>   r.right = x + width;
>   r.bottom = y + height;
…
>   HDC comp_dc = CreateCompatibleDC(hdc);
>   SelectObject (comp_dc, bm);
>   InvertRect (comp_dc, &r);
…
> }
> --8<---------------cut here---------------end--------------->8---
>
> Also i'm wondering if BitBlt can be another solution too.

Using BitBlt on the target DC would be trying to fix the misdraw after
the fact. You’d also have to invent a combination of a rop (raster
operation) and whichever auxiliary argument it takes so that it turns
the foreground color into the background color and vice versa.

BitBlt could be used on a memory DC into which the stipple bitmap is
selected, to emulate InvertRect, e.g. passing a rop of DSTINVERT, but
this brings no benefits.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]