A RAW image in our application is an array of 8 bit values (interpreted as grey scale intensity),
to which we have to supply image width, image height and BPP.
Here's our code:
int Width = JPEGImage.getWidth();
int Height = JPEGImage.getHeight();
int Components = JPEGImage.getComponents();
int Length = JPEGImage.getWidth() * JPEGImage.getHeight() * JPEGImage.getComponents();
Magick::Blob MyBlob(JPEGImage.releaseRAW(),Length);
Magick::Image MyImage(MyBlob,Magick::Geometry(Width,Height),8,"GRAY");
JPEGImage is a well tested internal class in our project, the method releaseRAW provides a char * pointer to RAW image data.
For most images this works fine, however, if the first two bytes of image data are "BA", the Magick::Image constructor throws an exception:
terminate called after throwing an instance of 'Magick::ErrorCorruptImage'
what(): ImageMagick: Improper image header `' @ bmp.c/ReadBMPImage/593
Aborted
This is very frustrating because the code explicitly tells ImageMagick++ to handle this data as GRAY, not as BMP data
