Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Airon65
Posts: 75 Joined: 2017-02-26T02:19:38-07:00
Authentication code: 1151
Post
by Airon65 » 2017-03-15T18:38:19-07:00
I want to put one image over/under another one. For example:
Code: Select all
Magick::Image img1( "images/image1.png" );
Magick::Image img2( "images/image2.png" );
img1.draw( img2, 50, 100 ); // <-- 50x100 - my desirable position for placing img2
img1.write( "output.png" );
How can I get it?
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2017-03-15T19:11:25-07:00
Your previous post
viewtopic.php?f=23&t=31571 showed a correct use of img.draw. And the doc
http://www.imagemagick.org/Magick++/Image++.html says that's the only way to use it: with a list of Drawable objects. The list can contain only one element.
In that doc, click on Drawable to get a page of Drawable objects. One of those involves an image with x and y coordinates.
Airon65
Posts: 75 Joined: 2017-02-26T02:19:38-07:00
Authentication code: 1151
Post
by Airon65 » 2017-03-16T07:07:08-07:00
Sorry, but I don't understand your answer
I understand that I need to draw it as a list (std::vector) of drawables. But I don't understand how can I do it:
Code: Select all
std::vector < Drawable > arr;
arr.push_back( DrawableImage( img1, 50, 100 ) ); // <-- I don't know how to add an image to the list
img2.draw( arr );
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2017-03-16T07:33:12-07:00
I don't use C++ so I don't use Magick++. But it took me only five minutes to find out how to do it, by following the documentation trail I showed you.
I strongly suggest you read the documentation. It isn't always perfect, but in this case at least it led to the solution:
Code: Select all
img1.draw( DrawableCompositeImage( 50, 100, img2 ));