Simple Read/Writing with Magick++ 6.7.8 stopped working?
Posted: 2012-07-05T04:27:56-07:00
I guess something has changed in the latest(s) releases of ImageMagick. The following program does not work as intented with Magick++ 6.7.8 (at least) anymore:
The reloaded pixels give very different values than the original ones. Do I need to do something else to get this example working? Or is it just a nasty bug.
To compile this app, I use ImageMagick 6.7.8 on OSX with MacPorts, but I think this is probably platform agnostic:
The output I get:
Where I was expecting to get a matching output - as before.
Thanks for any hints, Andre
Code: Select all
#include <iostream>
#include <ImageMagick/Magick++.h>
int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "usage: " << argv[0] << " <filename>" << std::endl;
exit(1);
}
char test_image[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
// save sample image
Magick::Image image;
image.size(Magick::Geometry(4, 6));
//image.colorSpace(Magick::GRAYColorspace);
image.read(4, 3, "I", Magick::CharPixel, test_image);
image.depth(8*sizeof(char));
image.write(argv[1]);
// reload sample image
Magick::Image reloaded(argv[1]);
char test_reload[24];
reloaded.write(0, 0, 4, 3, "I", Magick::CharPixel, test_reload);
std::cout << "original x reloaded:" << std::endl;
for (int i=0; i<12; ++i) {
std::cout << " " << (int)test_image[i] << ", "
<< (int)test_reload[i] << std::endl;
}
exit(0);
}
To compile this app, I use ImageMagick 6.7.8 on OSX with MacPorts, but I think this is probably platform agnostic:
Code: Select all
g++ -g -I /opt/local/include -I /opt/local/include/ImageMagick -L /opt/local/lib -lMagick++ test.cc
Code: Select all
original x reloaded:
1, 0
2, 0
3, 0
4, 0
5, 0
6, 0
7, 1
8, 1
9, 1
10, 1
11, 1
12, 1
Thanks for any hints, Andre