Board index » delphi » Drawing coloured bitmaps on monochrome image

Drawing coloured bitmaps on monochrome image

I can't understand what's happening here and would appreciate some help.

I'm trying to draw coloured (red) crosses on the canvas of a black and
white image loaded into a TImage component, but the crosses always came
out black - until I discovered by chance that if I swap the image out to

a temporary bitmap object (before I've drawn any crosses) and swap it
back, my crosses appear red. So this works for me, but I have no idea
why! Can anyone suggest why or a better way?

Thanks

Alan Hale

 

Re:Drawing coloured bitmaps on monochrome image


Quote
Alan Hale wrote:
> I'm trying to draw coloured (red) crosses on the canvas of a black and
> white image loaded into a TImage component, but the crosses always came
> out black - until I discovered by chance that if I swap the image out to

> a temporary bitmap object (before I've drawn any crosses) and swap it
> back, my crosses appear red. So this works for me, but I have no idea
> why! Can anyone suggest why or a better way?

Maybe TImage.Picture.Bitmap.PixelFormat is pf1Bit? Try to set
PixelFormat to e.g. pf24Bit before drawing the cross.

(The PixelFormat property is available for Delphi versions >= 3 only.)

Greetings, Robert
--
Robert Ro?mair
http://home.t-online.de/home/Robert.Rossmair/
Programming environment: Delphi 3.0, WinNT 4.0 SP5

Re:Drawing coloured bitmaps on monochrome image


Quote
> Maybe TImage.Picture.Bitmap.PixelFormat is pf1Bit? Try to set
> PixelFormat to e.g. pf24Bit before drawing the cross.

Yes, that's it. I appreciate your trouble. Many thanks

Alan Hale

Other Threads