Added methods to enable/disable OpenCL.
Removed deprecated method 'cacheThreshold' from Image.cpp.
using namespace std;
#include "Magick++/Functions.h"
+#include "Magick++/Exception.h"
+
+#define GetPPException \
+ ExceptionInfo \
+ exceptionInfo; \
+ GetExceptionInfo(&exceptionInfo)
+#define ThrowPPException \
+ throwException(exceptionInfo); \
+ (void) DestroyExceptionInfo(&exceptionInfo)
+
+static bool magick_initialized=false;
// Clone C++ string as allocated C string, de-allocating any existing string
-void Magick::CloneString( char **destination_, const std::string &source_ )
+void Magick::CloneString(char **destination_, const std::string &source_)
+{
+ MagickCore::CloneString(destination_,source_.c_str());
+}
+
+MagickPPExport void Magick::CacheThreshold(const MagickSizeType threshold_)
{
- MagickCore::CloneString( destination_, source_.c_str() );
+ (void) SetMagickResourceLimit(MemoryResource,threshold_);
}
+
+MagickPPExport MagickCore::MagickSizeType Magick::CacheThreshold(void)
+{
+ return GetMagickResourceLimit(MemoryResource);
+}
+
+MagickPPExport void Magick::DisableOpenCL(void)
+{
+ GetPPException;
+ MagickCore::InitImageMagickOpenCL(MagickCore::MAGICK_OPENCL_OFF,NULL,NULL,
+ &exceptionInfo);
+ ThrowPPException;
+}
+
+MagickPPExport void Magick::EnableOpenCL(const bool useCache_)
+{
+ GetPPException;
+ if (useCache_)
+ MagickCore::InitImageMagickOpenCL(
+ MagickCore::MAGICK_OPENCL_DEVICE_SELECT_AUTO,NULL,NULL,&exceptionInfo);
+ else
+ MagickCore::InitImageMagickOpenCL(
+ MagickCore::MAGICK_OPENCL_DEVICE_SELECT_AUTO_CLEAR_CACHE,NULL,NULL,
+ &exceptionInfo);
+ ThrowPPException;
+}
+
+MagickPPExport void Magick::InitializeMagick(const char *path_)
+{
+ MagickCore::MagickCoreGenesis(path_,MagickFalse);
+ if (!magick_initialized)
+ magick_initialized=true;
+}
+
+MagickPPExport void Magick::TerminateMagick(void)
+{
+ if (magick_initialized)
+ {
+ magick_initialized=false;
+ MagickCore::MagickCoreTerminus();
+ }
+}
\ No newline at end of file
MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
-static bool magick_initialized=false;
-
MagickPPExport int Magick::operator == (const Magick::Image &left_,
const Magick::Image &right_)
{
return((left_ < right_) || ( left_ == right_));
}
-MagickPPExport void Magick::InitializeMagick(const char *path_)
-{
- MagickCore::MagickCoreGenesis(path_,MagickFalse);
- if (!magick_initialized)
- magick_initialized=true;
-}
-
-MagickPPExport void Magick::TerminateMagick(void)
-{
- if (magick_initialized)
- {
- magick_initialized=false;
- MagickCore::MagickCoreTerminus();
- }
-}
-
Magick::Image::Image(void)
: _imgRef(new ImageRef)
{
return(constOptions()->boxColor());
}
-void Magick::Image::cacheThreshold(const MagickSizeType threshold_)
-{
- SetMagickResourceLimit(MemoryResource, threshold_);
-}
-
void Magick::Image::channelDepth(const size_t depth_)
{
modifyImage();
//
#ifndef MagickPlusPlus_Header
#include <Magick++/Include.h>
+#include <Magick++/Functions.h>
#include <Magick++/Image.h>
#include <Magick++/Pixels.h>
#include <Magick++/STL.h>
namespace Magick
{
- void MagickPPExport CloneString( char **destination_, const std::string &source_ );
+ // Pixel cache threshold in bytes. Once this memory threshold is exceeded,
+ // all subsequent pixels cache operations are to/from disk
+ MagickPPExport void CacheThreshold(const MagickSizeType threshold_);
+ MagickPPExport MagickSizeType CacheThreshold(void);
+ // Clone C++ string as allocated C string, de-allocating any existing string
+ MagickPPExport void CloneString(char **destination_,
+ const std::string &source_);
+
+ // Disable OpenCL acceleration (only works when build with OpenCL support)
+ MagickPPExport void DisableOpenCL(void);
+
+ // Enable OpenCL acceleration (only works when build with OpenCL support)
+ MagickPPExport void EnableOpenCL(const bool useCache_=true);
+
+ // C library initialization routine
+ MagickPPExport void InitializeMagick(const char *path_);
+
+ // C library initialization routine
+ MagickPPExport void TerminateMagick();
}
#endif // Magick_Functions_header
MagickPPExport int operator <=
(const Magick::Image &left_,const Magick::Image &right_);
- // C library initialization routine
- MagickPPExport void InitializeMagick(const char *path_);
- MagickPPExport void TerminateMagick();
-
//
// Image is the representation of an image. In reality, it actually
// a handle object which contains a pointer to a shared reference
void boxColor(const Color &boxColor_);
Color boxColor(void) const;
- // Pixel cache threshold in bytes. Once this memory threshold
- // is exceeded, all subsequent pixels cache operations are to/from
- // disk. This setting is shared by all Image objects.
- static void cacheThreshold(const MagickSizeType threshold_);
-
// Set or obtain modulus channel depth
void channelDepth(const size_t depth_);
size_t channelDepth();
#include "MagickCore/monitor.h"
#include "MagickCore/montage.h"
#include "MagickCore/morphology.h"
+#include "MagickCore/opencl.h"
#include "MagickCore/option.h"
#include "MagickCore/paint.h"
#include "MagickCore/pixel.h"