Page 1 of 2
Read 32bit bmp weird
Posted: 2014-12-08T03:18:52-07:00
by wizard29
Hi.
I read a 32bit bmp file. As result, I have a transparent image and RGB values is correct.
However, the source file contains an opaque image.
Maybe I am doing somthing wrong, but in case of a 24bit bmp image file the result is OK.
Looks like a bug.
I use IM 6.9.0 + Magick++.
Code: Select all
Magick::Image image;
try
{
image.read(utf8FileName);
image.colorSpace(Magick::sRGBColorspace);
image.type(Magick::TrueColorMatteType);
size_t height = image.rows();
size_t width = image.columns();
for (size_t i = 0; i < height; ++i)
{
const Magick::PixelPacket* pRow = image.getConstPixels(0, i, width, 1);
for (size_t j = 0; j < width; ++j)
{
std::cout<<static_cast<unsigned char>(pRow->opacity);//always 255 in case of a 32 bit bmp file, but 0 in case of a 24bit bmp file.
++pRow;
}
}
}
catch (const Magick::Exception& e)
{
std::cout<<e.what();
}
Re: Read 32bit bmp weird
Posted: 2014-12-08T07:34:14-07:00
by snibgo
You should provide sample input files that show the problem. You can upload to somewhere like dropbox.com and paste the URLs here.
Re: Read 32bit bmp weird
Posted: 2014-12-08T07:57:13-07:00
by wizard29
snibgo wrote:You should provide sample input files that show the problem. You can upload to somewhere like dropbox.com and paste the URLs here.
32bitbmp
same16bitbmp
Re: Read 32bit bmp weird
Posted: 2014-12-08T08:25:56-07:00
by snibgo
I can't see those files without signing in to Google.
Re: Read 32bit bmp weird
Posted: 2014-12-08T08:34:45-07:00
by wizard29
snibgo wrote:I can't see those files without signing in to Google.
I am sorry.
I fixed share settings for this links. You can try to download again.
Re: Read 32bit bmp weird
Posted: 2014-12-08T09:09:56-07:00
by snibgo
Where did 32bit.bmp come from? According to "identify", all the pixels have alpha=0, which is fully transparent.
Re: Read 32bit bmp weird
Posted: 2014-12-08T09:48:23-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-1 Beta available by sometime tomorrow. Thanks.
Re: Read 32bit bmp weird
Posted: 2014-12-08T23:53:40-07:00
by wizard29
snibgo wrote:Where did 32bit.bmp come from? According to "identify", all the pixels have alpha=0, which is fully transparent.
I used the CS6 to save an image as bmp with 32bit settings.
Re: Read 32bit bmp weird
Posted: 2014-12-09T01:53:27-07:00
by wizard29
For above images now works good. But does not work for
CS,
CSwithAlpha and
IM,
IMwithAlpha images.
The IM and IMwithAlpha images are files created via the IM Magick::Image::write call. Before the fix it worked fine.
Re: Read 32bit bmp weird
Posted: 2014-12-09T05:21:56-07:00
by magick
Looks like your original BMP image has the alpha channel backwards. It likely has a 1-alpha channel instead of alpha. Track down the BMP specification and see what it says about 32 bit alpha. Is 0 transparent or opaque?
Re: Read 32bit bmp weird
Posted: 2014-12-09T05:42:33-07:00
by wizard29
Maybe you are right, but I add some semi-transparent areas on some images (CSwithAlpha, IMwithAlpha). But CSwithAlpha image looks absolutely transparent after reading and IMwithAlpha has inverted alpha.
Re: Read 32bit bmp weird
Posted: 2014-12-09T05:58:43-07:00
by wizard29
You right it is correct behaviour you described. But:
Code: Select all
...
std::cout<<static_cast<unsigned char>(pRow->opacity);//always 255 in case of the CSwithAlpha file, but 0 in case of the 32bitbmp file.
...
Re: Read 32bit bmp weird
Posted: 2014-12-09T06:12:10-07:00
by wizard29
Thanks a lot, since the 17184 revision it works correct.
Re: Read 32bit bmp weird
Posted: 2014-12-09T06:16:11-07:00
by wizard29
But the 32bitbmp is absolutely transparent again.
Re: Read 32bit bmp weird
Posted: 2014-12-09T07:49:12-07:00
by magick
Right. We reverted until we see the specification. For 32-bit BMP, is alpha 0, transparent or opaque. Sometimes image generators get it wrong and you'll see a complete transparent image where it should be opaque.