Magic++ and Pixel-level access
Posted: 2010-10-18T14:39:40-07:00
I am able to compile a C++ application that is able to read an image and display information about it. I found some documentation about how to get to the individual pixels, and my application compiles.
However, when it gets to the reading of a specific pixel (the PixelPacket part), I get this error:
Assertion failed: (list_info != (LinkedListInfo *) NULL), function GetLastValueInLinkedList, file magick/hashmap.c, line 466.
Abort trap
Any thoughts?
However, when it gets to the reading of a specific pixel (the PixelPacket part), I get this error:
Assertion failed: (list_info != (LinkedListInfo *) NULL), function GetLastValueInLinkedList, file magick/hashmap.c, line 466.
Abort trap
Any thoughts?
Code: Select all
#include <iostream>
#include <Magick++.h>
using namespace std;
using namespace Magick;
int main(int argc, char* argv[]) {
if (argc != 2) {
cerr << "Proper usage: " << argv[0] << " <image-file>" << endl;
return -1;
}
InitializeMagick(*argv);
#ifdef DEBUG
cout << "ImageMagick initialized" << endl;
#endif
Image image;
Blob blob;
try {
image.read( argv[1] );
image.write( &blob );
}
catch( Exception &error_ ) {
cerr << "ImageMagick exception: " << error_.what() << endl;
return -2;
}
#ifdef DEBUG
cout << "About the image file..." << endl;
cout << "File size: " << image.fileSize() << " bytes"<< endl;
cout << "Format: " << image.format() << endl;
cout << "Endian: " << image.endian() << endl;
cout << "Size: " << image.size().height() << "x" << image.size().width() << endl;
cout << "Density: " << image.density().height() << "x" << image.density().width() << endl;
#endif
Pixels view(image);
for(ssize_t i = 0; i < (unsigned) image.size().height(); i++) {
for(ssize_t j = 0; j < (unsigned) image.size().width(); j++) {
PixelPacket *pixels = view.get(i,j,i+1,j+1); // Doesn't work, why?
}
}
return 0;
}