I read RGBA image raw data produced from another program and encode it to jpeg.
Most of time my codes work well, until I got this raw data that throw exception "static planes value not equal to 1".
Here is my short, self contained, example code. Sorry for the ugly hard coded numbers and strings, I just want to make it simple:
Code: Select all
int main(int argc, char **argv)
{
int raw_buf_size = 4304768;
char *raw_buf = (char *)malloc(raw_buf_size);
FILE *f = fopen("magick_exception_1352x796_censored.data", "rb");
if (f && raw_buf)
{
fread(raw_buf, 1, raw_buf_size, f);
fclose(f);
}
Magick::Blob blob;
blob.updateNoCopy(raw_buf, raw_buf_size, Magick::Blob::MallocAllocator);
Magick::Image img;
img.size("1352x796");
img.magick("RGBA");
img.depth(8);
try {
img.read(blob); // <- throw exception here
}
catch (std::exception &e)
{
printf("%s\n", e.what());
return -1;
}
img.magick("JPEG");
return 0;
}
https://imgs-sandbox.intsig.net/icr/dem ... sored.data
Which is RGBA raw data, 1352 * 796 pixels. This raw data seems fine and is not corrupted, I can use GIMP 2 to load this raw data.
I want to know why Magick++ throw that exception and how can I fix it.
Thank you!