No it's not a bug in IM. But I can't figure out how to replicate a command line which uses distort. I get a rather odd result depending on the input image.
When the input file to the program below has an alpha channel *and* the edges of the image are themselves transparent, like this
http://members.shaw.ca/el.supremo/logo_paintflood.png, the virtual pixel method works. But if I paint around the edge of the image with white and then use that as input (e.g. this
http://members.shaw.ca/el.supremo/logo_distort_pf.png), the virtual pixel method fails. In both cases, the equivalent command line works so there must be some sort of default action hidden within the convert command.
Pete
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
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_distort_pf.png");
// -matte is the same as -alpha on
MagickSetImageAlphaChannel(mw,SetAlphaChannel);
/*
For a list of valid virtual pixel methods in your version of IM
use the command:
convert -list virtualpixel
*/
MagickSetImageVirtualPixelMethod(mw,TransparentVirtualPixelMethod);
// 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();
}