Page 1 of 1

How to set "distort:viewport=WxH" for the distort function in magick++?

Posted: 2018-07-07T06:25:38-07:00
by lq634254672
I have found distort function has only 4 parameters in magick++, such as Image.distort(PerspectiveDistortion,16,point_4,false). Now i want to define "distort:viewport=WxH" to get a specified output. What do i do?

Re: How to set "distort:viewport=WxH" for the distort function in magick++?

Posted: 2018-07-07T06:48:03-07:00
by snibgo

Re: How to set "distort:viewport=WxH" for the distort function in magick++?

Posted: 2018-07-07T08:48:00-07:00
by lq634254672
Thanks very much, and now, i have another problem: i use the following codes to get a specified output with transparent background. But the background is not transparent overall, it has a corner with gray color. Is there something wrong of the code?

Code: Select all

Image image( filename );
image.artifact("distort:viewport","540x960");
image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
image.distort(PerspectiveDistortion,16,point_4,false);
image.write("distort.png");

Re: How to set "distort:viewport=WxH" for the distort function in magick++?

Posted: 2018-07-08T02:22:06-07:00
by lq634254672
lq634254672 wrote:
2018-07-07T08:48:00-07:00
Thanks very much, and now, i have another problem: i use the following codes to get a specified output with transparent background. But the background is not transparent overall, it has a corner with gray color. Is there something wrong of the code?

Code: Select all

Image image( filename );
image.artifact("distort:viewport","540x960");
image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
image.distort(PerspectiveDistortion,16,point_4,false);
image.write("distort.png");
Thanks very much. I have found the problem. I corrected my code as follows, it is work for me.

Code: Select all

image.artifact("distort:viewport","540x960");
image.matteColor(Color("transparent") );
image.virtualPixelMethod(Magick::TransparentVirtualPixelMethod);
image.distort(PerspectiveDistortion,16,point_4,false);
image.write("distort.png");