Using interface magickwand
Code: Select all
//read a image src.jpg to handler magick_wand
...
MagickSetImageMatte(magick_wand,MagickTrue);
MagickSetImageVirtualPixelMethod(magick_wand,TransparentVirtualPixelMethod);
...
MagickDistortImage(magick_wand,AffineProjectionDistortion,6,doubleArray,MagickFalse);
//want to get a transparent background PNG file
MagickWriteImage(magick_wand,"out.png");
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <magick/MagickCore.h>
int
main(int argc,char **argv)
{
ExceptionInfo *exception;
Image *image,*after;
ImageInfo *image_info;
if(argc != 3)
{
(void)fprintf(stdout,"usage invalid!");
exit(0);
}
MagickCoreGenesis(*argv,MagickTrue);
exception=AcquireExceptionInfo();
image_info=CloneImageInfo((ImageInfo*)NULL);
(void)strcpy(image_info->filename,*(argv+1));
image=ReadImage(image_info,exception);
double arr[6]={0.739,0,0,0.739,63,-79};
//SetMatte(MagickTrue);
SetImageVirtualPixelMethod(image,8);
after=DistortImage(image,AffineProjectionDistortion,6,arr,MagickFalse,exception);
(void)strcpy(after->filename,argv[2]);
WriteImage(image_info,after);
}
and last using DistortImage,but can't get the same result as using magickWand.
i found in magickCore there is a API function :
Code: Select all
MagickBooleanType DrawAffineImage(Image *image,const Image *source,
const AffineMatrix *affine)