OpenShot Library | libopenshot  0.3.3
MagickUtilities.h
Go to the documentation of this file.
1 
8 // Copyright (c) 2008-2019 OpenShot Studios, LLC
9 //
10 // SPDX-License-Identifier: LGPL-3.0-or-later
11 
12 #ifndef OPENSHOT_MAGICK_UTILITIES_H
13 #define OPENSHOT_MAGICK_UTILITIES_H
14 
15 #ifdef USE_IMAGEMAGICK
16 
17  // Avoid a bug in the interaction between ImageMagick
18  // and the standard C insertion headers, which can
19  // cause functions used by macros in the standard C
20  // assertion code to be put in an ImageMagick library
21  // namespace instead of the global namespace
22  #include <cassert>
23 
24  #include <memory>
25  #include <QImage>
26 
27 // Exclude a warning message with IM6 headers
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
30  #include "Magick++.h"
31 #pragma GCC diagnostic pop
32 
33  // Determine ImageMagick version, as IM7 isn't fully
34  // backwards compatible
35  #ifndef NEW_MAGICK
36  #define NEW_MAGICK (MagickLibVersion >= 0x700)
37  #endif
38 
39  // IM7: <Magick::Image>->alpha(bool)
40  // IM6: <Magick::Image>->matte(bool)
41  #if NEW_MAGICK
42  #define MAGICK_IMAGE_ALPHA(im, a) im->alpha((a))
43  #else
44  #define MAGICK_IMAGE_ALPHA(im, a) im->matte((a))
45  #endif
46 
47  // IM7: vector<Magick::Drawable>
48  // IM6: list<Magick::Drawable>
49  // (both have the push_back() method which is all we use)
50  #if NEW_MAGICK
51  #define MAGICK_DRAWABLE std::vector<Magick::Drawable>
52  #else
53  #define MAGICK_DRAWABLE std::list<Magick::Drawable>
54  #endif
55 
56 namespace openshot {
57 
59  std::shared_ptr<Magick::Image>
60  QImage2Magick(std::shared_ptr<QImage>);
61 
63  std::shared_ptr<QImage>
64  Magick2QImage(std::shared_ptr<Magick::Image>);
65 
66 } // namespace
67 
68 #endif // USE_IMAGEMAGICK
69 #endif // OPENSHOT_MAGICK_UTILITIES_H
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::QImage2Magick
std::shared_ptr< Magick::Image > QImage2Magick(std::shared_ptr< QImage >)
Convert QImage to Magick::Image.
Definition: MagickUtilities.cpp:21
openshot::Magick2QImage
std::shared_ptr< QImage > Magick2QImage(std::shared_ptr< Magick::Image >)
Convert Magick::Image to QImage.
Definition: MagickUtilities.cpp:46