I 开发者_JAVA技巧have a PNG (32-bit) image in a TImage. A form has a Glass Frame. Picture's background is black, not transparent. How to fix it?
Delphi 2010.
Thanks.
As workaround you can change the bits of your png image to 32.
Check this sample
the left image is a PNG of 8 bits and the other is of 32 bits.
You should forget about the TImage as it won't handle the blit right. You need to use GDI+ to manually draw the image on your form. That's only because of the "glass". IF you leave it up the the TImage (or actually the TGraphic displayed in it!), the "background" (glass) will be copied into memory and onto that, a transparant graphic (png?) will be composed, and blitted back tot he form. Unfortunately, the "background" (the glass) will turn out to be black when you blt it back.
So, use GDI+ (google it) and blt using the bitmap.handle. Make sure the bitmap is transparent (i.e. 32bits and the appropriate properties set).
Same with fonts on glass, btw. You have to draw stuff yourself (maybe from a custom component?). You can find a few components that do this already, though... Like http://development.mwcs.de/glowlabel.html.
精彩评论