Code: Select all
#include <iostream>
#include <Magick++.h>
unsigned char imageData[] = {
0xff, 0xff, 0xff, 0xff, // super black
0x00, 0x00, 0x00, 0x00, // white
0xff, 0x00, 0x00, 0x00, // cyan
0x00, 0xff, 0x00, 0x00, // magenta
0x00, 0x00, 0xff, 0x00, // yellow
0x00, 0x00, 0x00, 0xff, // black
0x00, 0xff, 0xff, 0x00, // red
0xff, 0x00, 0xff, 0x00, // green
0xff, 0xff, 0x00, 0x00, // blue
0x00, 0x00, 0x00, 0x00, // white
0xff, 0xff, 0xff, 0xff // super black
};
#define IMAGE_WIDTH 11
#define IMAGE_HEIGHT 1
unsigned char outputImage[IMAGE_WIDTH * IMAGE_HEIGHT * 4];
int main (int argc, char * const argv[]) {
std::cout << "Hello, World!\n";
Magick::Image image( IMAGE_WIDTH, IMAGE_HEIGHT, "CMYK", Magick::CharPixel, imageData );
//image.type(Magick::TrueColorType);
image.write("/tmp/test.png");
image.modifyImage();
//image.blur(30, 10);
image.syncPixels();
Magick::Pixels view(image);
Magick::PixelPacket *pixels = view.get(0,0,IMAGE_WIDTH,IMAGE_HEIGHT);
FILE *f = fopen("/tmp/test.txt", "w");
for ( int row = 0; row < IMAGE_HEIGHT ; ++row )
for ( int column = 0; column < IMAGE_WIDTH ; ++column ) {
fprintf(f, "%8d\t%8d\t%8d\t%8d\n",
pixels->red, pixels->green, pixels->blue, pixels->opacity);
pixels++;
}
fprintf(f, "\n");
fclose(f);
return 0;
}
Code: Select all
0 0 0 0
65535 65535 65535 0
0 65535 65535 0
65535 0 65535 0
65535 65535 0 0
0 0 0 0
65535 0 0 0
0 65535 0 0
0 0 65535 0
65535 65535 65535 0
0 0 0 0
I appreciate any advice. Thank you. (Oh, I'm running ImageMagick-6.5.6-5 under Mac OS X 10.5.7 if that matters)
John