Re: Use of C gm function inside C++ code (AutoOrientImage example)

Przemysław Sobala <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <CAGKkJoouQrgdqHt_HF0pnEd60PQwVPo_4mGiPLdWX6vg6UOqdw@mail.gmail.com>
On Wed, Nov 22, 2017 at 10:14 PM, Bob Friesenhahn <
[email protected]> wrote:

> 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
>

I've done that in patch #53 (
https://sourceforge.net/p/graphicsmagick/patches/53/)
--
Regards
Przemysław Sobala

------------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.