[Lazarus] Transparent (key color based) drawing questions

Max Vlasov max.vlasov at gmail.com
Thu Jul 14 12:37:01 CEST 2011


Hi,
I used the technique described here
  http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Drawing_color_transparent_bitmaps
for transparent drawing on windows. So when porting to cross-platform
used this example.

Two observations:

1. At least on linux gtk the order of assignments should be reverse

On the site
  bmp.Transparent := True;
  bmp.TransparentColor := clFuchsia;

But the correct order is
  bmp.TransparentColor := clFuchsia;
  bmp.Transparent := True;

because probably in the first case the color assignment invalidates
Masked (= Transparent). Seems like every next call is ok because the
mask is already created. If my case when the program started, the
result was non-transparent, and the problem is fixed only when I
mimimize and restore the window

Either it would be great to fix this in the example (mentioning this
side effect in the comment) or change the code to be more universal.

2. Another moment is that as I see Canvas.CopyRect is not compatible
with this transparent drawing. At least I see no visual results and no
masked procedures are called. Probably this is by design, but this
means that it's not possible to draw different parts of transparent
bitmaps. Currently I copied and adapted the lines from
TRasterImage.Draw, but the suggestion is to create public, method
(non-existed before) for advanced drawing and TRasterImage.Draw just
will use it with some default parameters. Actually this method won't
be a threat for the binary size increase because TRasterImage.Draw is
already ready for this, just uses four hard-coded zeros in the
StretchMaskBlt call

Also maybe CopyRect incompatibility is also worth mentioning in the example

Thank you,

Max




More information about the Lazarus mailing list