How to do matrix-transform by magickCore
Posted: 2009-08-03T04:16:10-07:00
it works well(do matrix-transform and output a png file) if u using ImageMagick6.4.6-7 or higer Version
Using interface magickwand
but I using similar method in magickCore,failed.
first i use setMatte(true),and then SetImageVirtualPixelMethod,
and last using DistortImage,but can't get the same result as using magickWand.
i found in magickCore there is a API function :
Do i need use this function to do matrix-transform? I am so worried about this question.
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)