Re: Use of C gm function inside C++ code (AutoOrientImage example)
Bob Friesenhahn <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 22 Nov 2017, Przemysław Sobala wrote:
> Hello
>
> What's the best way I can use a C libGraphicsMagick function in C++ code?
>
> Let's use AutoOrientImage (from magick/shear.h) as an example.
> I tried:
>
>
> Magick::Image image;
> image.read(.....)
>
> // auto orient
> MagickLib::ExceptionInfo tmpException;
> MagickLib::Image *tmpImage = AutoOrientImage(image.image(),
> image.orientation(), &tmpException);
> image.replaceImage(tmpImage);
The best thing to do is to implement the missing method in the
Magick++ library itself and send us a patch so it can be added. :-)
A typical method implementation (in the library) is:
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickLib::Image* newImage =
AddNoiseImageChannel ( image(),
channel_,
noiseType_,
&exceptionInfo );
replaceImage( newImage );
throwImageException( exceptionInfo );
which is very close to what you have except your code is missing the
GetExceptionInfo( &exceptionInfo );
line. Initializing this structure is important since it contains
pointer members and some decisions are made based on its current
state.
Bob
--
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help