I've seen many questions asking how to draw transparent images, but my case is quite the opposite. I have a TPicture
where I load any file type, including PNG
. I then read TPicture.Graphic
and call Draw
directly in a TBitmap
's canvas. However, when the image is drawn, it carries over the transparency of the original PNG
image.
The current code is very simple, just...
MyPicture.LoadFromFile(SomeFilename);
MyBitmap.Canvas.StretchDraw(SomeRect, MyPicture.Graphic);
Now the issue is that the canvas which I'm drawing to already has an image, and this PNG is being drawn over a portion of it. When the PNG has a transparent background, normally it appears white. However, since it's directly drawing a transparent graphic to the canvas, it keeps those areas transparent.
How can I draw a PNG
Graphic directly to a canvas without its original transparency while using only the canvas drawing methods? I don't want to create too many graphic objects and draw too many times, hence the reason I only have 2 lines of code above. I'm hoping there's a way I can do something like BitBlt
with some special mechanism for this purpose.