Home | History | Annotate | Download | only in lib
      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-2015
      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
     23 MagickPPExport void Magick::CloneString(char **destination_,
     24   const std::string &source_)
     25 {
     26   MagickCore::CloneString(destination_,source_.c_str());
     27 }
     28 
     29 MagickPPExport void Magick::DisableOpenCL(void)
     30 {
     31   MagickCore::SetOpenCLEnabled(MagickFalse);
     32 }
     33 
     34 MagickPPExport bool Magick::EnableOpenCL(void)
     35 {
     36   bool
     37     status;
     38 
     39  status=MagickCore::SetOpenCLEnabled(MagickTrue) != MagickFalse;
     40  return(status);
     41 }
     42 
     43 MagickPPExport void Magick::InitializeMagick(const char *path_)
     44 {
     45   MagickCore::MagickCoreGenesis(path_,MagickFalse);
     46   if (!magick_initialized)
     47     magick_initialized=true;
     48 }
     49 
     50 MagickPPExport void Magick::SetRandomSeed(const unsigned long seed)
     51 {
     52   MagickCore::SetRandomSecretKey(seed);
     53 }
     54 
     55 MagickPPExport void Magick::TerminateMagick(void)
     56 {
     57   if (magick_initialized)
     58     {
     59       magick_initialized=false;
     60       MagickCore::MagickCoreTerminus();
     61     }
     62 }