Page 1 of 1

why after MagickAffineTransformImage called but no effect

Posted: 2008-11-20T21:15:12-07:00
by smileface
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

Re: why after MagickAffineTransformImage called but no effect

Posted: 2008-11-21T09:23:47-07:00
by el_supremo
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

I have found a solution to solve this problem

Posted: 2008-11-23T21:17:16-07:00
by smileface
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:)