Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wand/MagickWand.h>
#define ThrowWandException(wand) \
{ \
char \
*description; \
\
ExceptionType \
severity; \
\
description=MagickGetException(wand,&severity); \
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
description=(char *) MagickRelinquishMemory(description); \
exit(1); \
}
int main() {
int i = 0;
PixelWand *pix = NewPixelWand();
MagickWand *shadow = NULL;
MagickWand *wand = NewMagickWand();
MagickSetSize(wand, 100, 100);
PixelSetColor(pix, "black");
if (!MagickReadImage(wand, "magick:rose")) {
ThrowWandException(wand);
}
MagickWriteImage(wand, "orig.jpg");
MagickSetImageBackgroundColor(wand, pix);
for (i = 0; i < 100; i += 10) {
char fname[256];
memset(fname, 0, 256);
sprintf(fname, "img_%d.png", i);
shadow = CloneMagickWand(wand);
if (MagickShadowImage(shadow, 50, 1, i, i / 2) == MagickFalse) {
ThrowWandException(wand);
}
MagickWriteImage(shadow, fname);
DestroyMagickWand(shadow);
shadow = NULL;
}
DestroyPixelWand(pix);
DestroyMagickWand(wand);
}