Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
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.
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();
}
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.
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?
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.
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.