Code: Select all
#include <stdio.h>
#include <stdint.h>
#include <wand/MagickWand.h>
/* uint8_t data[4] = {156, 230, 5, 238}; */
uint8_t data[4] = {0x9c, 0xe6, 0x05, 0xee};
int main()
{
printf("%d %d %d %d\n", data[0], data[1], data[2], data[3]);
MagickWandGenesis();
MagickWand *magick_wand;
magick_wand = NewMagickWand();
MagickBooleanType status = MagickConstituteImage(magick_wand,2,2,"I",CharPixel,data);
uint8_t *buf = (uint8_t*) calloc(4,1); /* initialized to 0 */
MagickExportImagePixels(magick_wand,0,0,2,2,"I",CharPixel,buf);
printf("%d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
DestroyMagickWand(magick_wand);
MagickWandTerminus();
}
Something similar to this worked on the version distributed with Ubuntu 12.04.$ ./magick
156 230 5 238
85 202 0 218
If I've not made a mistake and this is a useful test, you're welcome to put this code (or a variant) in your unit tests under whichever license you choose.