Page 1 of 1

MagickShadowImage args have no effect

Posted: 2009-07-02T15:23:57-07:00
by mkoppanen

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);
}
Should the shadow geometry change?

Re: MagickShadowImage args have no effect

Posted: 2009-07-03T18:03:09-07:00
by magick
Try this:

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()
{
  PixelWand *background = NewPixelWand();
  MagickWand *rose, *shadow, *merge;
  MagickBooleanType status;

  rose=NewMagickWand();
  if (MagickReadImage(rose,"rose:") == MagickFalse)
    ThrowWandException(rose);
  shadow=CloneMagickWand(rose);
  PixelSetColor(background,"navy");
  MagickSetImageBackgroundColor(shadow,background);
  if (MagickShadowImage(shadow,80,3,5,5) == MagickFalse)
    ThrowWandException(shadow);
  status=MagickAddImage(shadow,rose);
  if (status == MagickFalse)
    ThrowWandException(rose);
  PixelSetColor(background,"none");
  MagickSetImageBackgroundColor(shadow,background);
  merge=MagickMergeImageLayers(shadow,MergeLayer);
  MagickWriteImage(merge,"rose.png");

  DestroyPixelWand(background);
  DestroyMagickWand(merge);
  DestroyMagickWand(shadow);
  DestroyMagickWand(rose);
}