I've been trying to get your perspective distort to work with a MagickWand program but without success.
I applied your perspective transformation to the built-in logo: image using the command line:
Code: Select all
convert logo: -matte -virtual-pixel transparent -distort Perspective \
'7,40 4,30 4,124 4,123 85,122 100,123 85,2 100,30' \
logo_d_p.png
which produces this image:
My program (below) produces this image:
@magick: I've tried all sorts of combinations of setting the options and imageproperties before and after the read, setting the background colour etc. and I can't get it to produce the transparent part that the command line produces. What am I missing here? (the program and command line are both using IM 6.4.4)
Pete
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(void)
{
MagickWand *mw = NULL;
double cpoints[16] = {
7,40, 4,30, 4,124, 4,123, 85,122, 100,123, 85,2, 100,30
};
MagickWandGenesis();
mw = NewMagickWand();
MagickReadImage(mw,"logo:");
// -matte is the same as -alpha on
MagickSetImageAlphaChannel(mw,SetAlphaChannel);
MagickSetImageProperty(mw,"virtual-pixel","transparent");
// and then apply the result to the image
MagickDistortImage(mw,PerspectiveDistortion,
16,(const double *)&cpoints,MagickFalse);
MagickWriteImage(mw,"logo_distort_p.png");
/* Clean up */
if(mw)mw = DestroyMagickWand(mw);
MagickWandTerminus();
}