[magick-users] Joining 2 image halves (C++ api)
bill_barrington at bellsouth.net
bill_barrington at bellsouth.net
Thu Oct 18 07:09:42 PDT 2007
Thanks for the reply. That was actually my first attempt. I put 2 instances of DrawableCompositeImage in a std::list<Drawable>. That didn't work, so I tried the code below.
And, by the way, I forgot to mention that the two image halves were created by using the IM chop method. So all I'm trying to do is recreate the image that was previously chopped in half.
Regards,
Bill
-------------- Original message ----------------------
From: Anthony Thyssen <anthony at griffith.edu.au>
>
> bill_barrington at bellsouth.net on wrote...
> | Hello,
> |
> | What I would like to do is very simple. Basically, I would like to use the C++
> API to perform the same thing that the following 'convert' command line tool
> does:
> | convert +append lhs rhs joined
> |
> | The C++ code follows. It's being called using JNI, hence the jints, etc. Can
> someone steer me to the solution? Thanks.
> |
> |
> | jint joinImageHalves(jbyte *lhs, jint lhsLen, jbyte *rhs, jint rhsLen, jbyte*
> &image) {
> | cerr << "Creating lhs" << endl;
> | Blob lhsBlob((unsigned char*)(lhs), lhsLen);
> | Image lhsImage(lhsBlob);
> |
> | cerr << "Creating rhs" << endl;
> | Blob rhsBlob((unsigned char*)(rhs), rhsLen);
> | Image rhsImage(rhsBlob);
> |
> | Geometry lhsGeom = lhsImage.size();
> | Geometry rhsGeom = rhsImage.size();
> | if(lhsGeom.width() != rhsGeom.width() || lhsGeom.height() !=
> rhsGeom.height())
> | throw invalid_argument("Geometry of image halves differs");
> | int w = lhsGeom.width();
> | int h = lhsGeom.height();
> |
> | Image joined(Geometry(w*2, h), Color("white")); // Canvas
> | cerr << "Created canvas" << endl;
> | joined.composite(lhsImage, 0, 0);
> | joined.composite(rhsImage, w, 0);
> |
> | cerr << "Writing to blob" << endl;
> | Blob imageBlob;
> |
> | // BLOWS UP HERE DURING THE WRITE TO THE BLOB
> | joined.write(&imageBlob);
> | // ...
>
> I am quite certian that a AppendImages type of function is
> available, however you will have to have both images form a single
> image sequence (or list) rather than as separate images.
>
> Remember IM 'image' data structure is a image sequence, of multiple
> images. and that is what append would be expecting.
>
> Sorry to be so vague, but I don't program in C++, but I know the
> MagickCore Library and I am expert in the command line usage of IM.
>
> Anthony Thyssen ( Graphics Enthusiast ) <A.Thyssen at griffith.edu.au>
> -----------------------------------------------------------------------------
> At 300 dpi you can tell she's wearing a swimsuit.
> At 600 dpi you can tell it's wet.
> At 1200 dpi you can tell it's painted on.
> I suppose at 2400 dpi you can tell if the paint is giving her a rash.
> -- Joshua R. Poulson
> -----------------------------------------------------------------------------
> IM Examples http://www.imagemagick.org/Usage/
More information about the Magick-users
mailing list