1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2002, 2003
4 // Copyright Dirk Lemstra 2014-2017
5 //
6 // Simple C++ function wrappers for ImageMagick equivalents
7 //
8
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11
12 #include "Magick++/Include.h"
13 #include <string>
14
15 using namespace std;
16
17 #include "Magick++/Functions.h"
18 #include "Magick++/Exception.h"
19
20 static bool magick_initialized=false;
21
22 // Clone C++ string as allocated C string, de-allocating any existing string
CloneString(char ** destination_,const std::string & source_)23 MagickPPExport void Magick::CloneString(char **destination_,
24 const std::string &source_)
25 {
26 MagickCore::CloneString(destination_,source_.c_str());
27 }
28
DisableOpenCL(void)29 MagickPPExport void Magick::DisableOpenCL(void)
30 {
31 MagickCore::SetOpenCLEnabled(MagickFalse);
32 }
33
EnableOpenCL(void)34 MagickPPExport bool Magick::EnableOpenCL(void)
35 {
36 bool
37 status;
38
39 status=MagickCore::SetOpenCLEnabled(MagickTrue) != MagickFalse;
40 return(status);
41 }
42
InitializeMagick(const char * path_)43 MagickPPExport void Magick::InitializeMagick(const char *path_)
44 {
45 MagickCore::MagickCoreGenesis(path_,MagickFalse);
46 if (!magick_initialized)
47 magick_initialized=true;
48 }
49
SetRandomSeed(const unsigned long seed)50 MagickPPExport void Magick::SetRandomSeed(const unsigned long seed)
51 {
52 MagickCore::SetRandomSecretKey(seed);
53 }
54
SetSecurityPolicy(const std::string & policy_)55 MagickPPExport bool Magick::SetSecurityPolicy(const std::string &policy_)
56 {
57 bool
58 status;
59
60 GetPPException;
61 status=MagickCore::SetMagickSecurityPolicy(policy_.c_str(),
62 exceptionInfo) != MagickFalse;
63 ThrowPPException(false);
64 return(status);
65 }
66
TerminateMagick(void)67 MagickPPExport void Magick::TerminateMagick(void)
68 {
69 if (magick_initialized)
70 {
71 magick_initialized=false;
72 MagickCore::MagickCoreTerminus();
73 }
74 }