However, I ran into a problem whereby the saved image created this way has matte set and when viewed in PSP X the vast majority of the image is just the transparent background. OTOH, just to be awkward, Windows Picture and Fax Viewer ignores the matte setting and shows the full screen image.
If I change the program so that it writes a test.bmp file consisting of a BMP file header followed by the DIB (exactly as was given to MagickReadImageBlob) and then use "convert test.bmp testa.bmp" the output file is a normal BMP with no matte even though convert sees precisely the same info.
I used SetLogEventMask to create debugging output which shows that the DIB coder handles the image from MagickReadImageBlob whereas the BMP coder handles it when doing a convert and they obviously interpret the image in slightly different ways.
In the bmp.c coder the matte is set like this:
and alpha_mask can be non-zero *only if* the BMP info header is more than 40 bytes long.
Code: Select all
image->matte=bmp_info.alpha_mask != 0 ? MagickTrue : MagickFalse;
The dib.c coder only handles 40 byte info headers - it throws an exception for any other size - and sets the matte like this:
The MSDN info that came with my Visual C++.net compiler does not have any mention of matte or transparency when it describes the 40 byte DIB info header not even when there are 32 bits per pixel. It appears that it is an error for the DIB coder to set the matte under any condition and perhaps that statement should be removed?
Code: Select all
image->matte=dib_info.bits_per_pixel == 32 ? MagickTrue : MagickFalse;
In the meantime, in my program I have added a MagickSetImageMatte call after the MagickReadImageBlob to force the matte off.