why after MagickAffineTransformImage called but no effect

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.

why after MagickAffineTransformImage called but no effect

Postby smileface » 2008-11-20T21:15:12+00:00

MagickBooleanType
status;

MagickWand
*magick_wand;

if (argc != 3)
{
(void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
exit(0);
}

MagickWandGenesis();
magick_wand=NewMagickWand();
status=MagickReadImage(magick_wand,argv[1]);
if (status == MagickFalse)
ThrowWandException(magick_wand);

DrawingWand *dwand=NewDrawingWand();
AffineMatrix affine;
affine.sx=2.0;
affine.rx=1.1,
affine.ry=1.1;
affine.sy=2.0;
affine.tx=-100.0;
affine.ty=-200.0;
AffineMatrix *aff=&affine;
DrawAffine(dwand,aff);
MagickBooleanType sta_trans=MagickAffineTransformImage(magick_wand,dwand);
MagickDrawImage(magick_wand,dwand);
DrawRender(dwand);

if(sta_trans==MagickFalse) ThrowWandException(magick_wand);
/*
Write the image then destroy it.
*/
status=MagickWriteImages(magick_wand,argv[2],MagickTrue);
if (status == MagickFalse)
ThrowWandException(magick_wand);
magick_wand=DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);


**********************
the out put image have not did affine .who can tell me why?
and Is it means i need use
MagickDistortImage (MagickWand *wand, const DistortImageMethod method, const unsigned long number_arguments, const double *arguments, const MagickBooleanType bestfit)
this function to do affineTransform.and my imageImagick vision is 6.4.6.1 install on RedHat as 4
Last edited by smileface on 2008-11-29T23:52:24+00:00, edited 1 time in total.
smileface
 

Re: why after MagickAffineTransformImage called but no effect

Postby el_supremo » 2008-11-21T09:23:47+00:00

I can't get affine to work either on IM 6.4.4 (Win XP)

This code just outputs an unmodified logo: image.

Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define ThrowWandException(x) MessageBox(NULL,"ERK","",MB_OK);
void test_wand(void) {
   MagickBooleanType status;
   MagickBooleanType sta_trans;
   
   MagickWand *magick_wand;
   DrawingWand *dwand;
   
   AffineMatrix affine;
   AffineMatrix *aff=&affine;
   
   MagickWandGenesis();
   
   magick_wand=NewMagickWand();
   status=MagickReadImage(magick_wand,"logo:");
   if (status == MagickFalse)ThrowWandException(magick_wand);
// translate and scale - no rotation
   affine.sx=.5;
   affine.rx=0;
   affine.ry=0;
   affine.sy=.5;
   affine.tx=-50;
   affine.ty=50;
   dwand = NewDrawingWand();
   DrawAffine(dwand,aff);
   sta_trans=MagickAffineTransformImage(magick_wand,dwand);
// This should be before MagickDrawImage but neither should be needed
// They don't do anything here anyway
//   DrawRender(dwand);
//   MagickDrawImage(magick_wand,dwand);

   if (sta_trans==MagickFalse) ThrowWandException(magick_wand);
//   MagickResetImagePage(magick_wand,"");
   /*
   Write the image then destroy it.
   */
   status=MagickWriteImage(magick_wand,"logo_affine.png");
   if (status == MagickFalse)ThrowWandException(magick_wand);
   magick_wand = DestroyMagickWand(magick_wand);
   dwand = DestroyDrawingWand(dwand);
   MagickWandTerminus();
//   return(0);
}

Pete
el_supremo
 
Posts: 1027
Joined: 2005-03-21T21:16:57+00:00

I have found a solution to solve this problem

Postby smileface » 2008-11-23T21:17:16+00:00

I have show the way in my blog.
If someone have met the same problem,u may just try to use this way to do the affine distortion.
this is the url:
http://blog.csdn.net/xmr_gxcfe/archive/ ... 58913.aspx
If u have other advices please tell me.Thanks:)
smileface
 


Return to Developers

Who is online

Users browsing this forum: Google [Bot] and 6 guests