The program first puts a black pixel in each corner of logo: so that you can see that in the final image the top row and right edge have each been extended by one pixel to produce the extension from the expected 480x630 to 481x641.
Pete
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define DegreesToRadians(a) (a*M_PI/180.)
// Set the affine array to rotate image by 'degrees' clockwise
double *set_rotate_affine(double r[],double degrees)
{
r[0] = cos(DegreesToRadians(fmod(degrees,360.0)));
r[1] = sin(DegreesToRadians(fmod(degrees,360.0)));
r[2] = -sin(DegreesToRadians(fmod(degrees,360.0)));
r[3] = cos(DegreesToRadians(fmod(degrees,360.0)));
r[4] = 0;
r[5] = 0;
return(r);
}
void test_wand(void) {
{
double r[6];
DrawingWand *dw = NULL;
PixelWand *pw = NULL;
MagickWand *mw = NULL;
MagickWandGenesis();
mw=NewMagickWand();
MagickReadImage(mw,"logo:");
// Put a black pixel in each of the corners
pw = NewPixelWand();
dw = NewDrawingWand();
PixelSetColor(pw,"black");
DrawSetFillColor(dw,pw);
DrawPoint(dw,0,0);
DrawPoint(dw,0,479);
DrawPoint(dw,639,479);
DrawPoint(dw,639,0);
MagickDrawImage(mw,dw);
// Do the affine rotation
MagickDistortImage(mw,AffineProjectionDistortion,
6,set_rotate_affine(r,90),MagickTrue);
// Output as GIF - avoid JPG artifacts
MagickWriteImage(mw,"logo_affine_4.gif");
if(mw)mw = DestroyMagickWand(mw);
if(dw)dw = DestroyDrawingWand(dw);
if(pw)pw = DestroyPixelWand(pw);
MagickWandTerminus();
}