Block don't support Fixed Transparency

I have found that bitmaps added to a Block do not support transparency in the way that 'ordinary' bitmaps do. Though the block has the Bitmap.Transparent, TransparentMode and TransparentColor properties, the mode & color have no effect. Instead the Block always uses the tmAuto mode (which uses the colour for the bottom left pixel as the Transparent colour). The implementation of the mode also gives results different to a basic StretchDraw, I get different pixels showing transparent.   


Got an image to illustrate...

Note the transparent area top right on the middle Block. These pixels are not the same color as the transparent pixels in the StretchDraw, tmAuto version. The source image for the right Block has the bottom left pixel set to black (it's too small to see once rendered inside the block)  

Hello David,

Diagram Studio doesn't take TransparentMode and TransparentColor into account when drawing bitmaps, unless you use the old GDI graphic lib:

atDiagram1.GraphicLib := dglGdi;

If you want to keep using the new Direct2D or GDI+ engines, I'd suggest you use transparent PNG images as it's a more modern way to draw transparent images.

Another top tip to add to the new manual ;-)

I will look into changing my app to generate PNGs instead of BMPs

.... OK, PNGs might be the more modern way, but it's certainly not simple....

I have manged to generate transparent PNGs - but how should I assign / copy / put the PNG into the TDiagramBlock? So far the only method I have found is to stream the PNG to a memorystream and then back into the TDiagramBlock. This works, but seems a bit convoluted!

This is a very simple example:


Yes, but I am generating the TPNGImage myself within the program so it seems very inefficient and poor practice to save the image I generate to a temp file then read it straight back in! 

If you have a TPNGImage, then just assign it to the picture:


Duhh. I actually had exactly that commented out in my code! I tried it but must have had something else wrong at the time.