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

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
lq634254672
Posts: 5
Joined: 2018-07-06T21:08:17-07:00
Authentication code: 1152

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

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

snibgo's IM pages: im.snibgo.com
lq634254672
Posts: 5
Joined: 2018-07-06T21:08:17-07:00
Authentication code: 1152

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

Post 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");
lq634254672
Posts: 5
Joined: 2018-07-06T21:08:17-07:00
Authentication code: 1152

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

Post 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");
Post Reply