1 // This may look like C code, but it is really -*- C++ -*- 2 // 3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002 4 // Copyright Dirk Lemstra 2014-2015 5 // 6 // Definition of an Image reference 7 // 8 // This is a private implementation class which should never be 9 // referenced by any user code. 10 // 11 12 #if !defined(Magick_ImageRef_header) 13 #define Magick_ImageRef_header 14 15 #include <string> 16 #include "Magick++/Include.h" 17 #include "Magick++/Thread.h" 18 19 namespace Magick 20 { 21 class Options; 22 23 // 24 // Reference counted access to Image * 25 // 26 class MagickPPExport ImageRef 27 { 28 public: 29 30 // Construct with null image and default options 31 ImageRef(void); 32 33 // Construct with an image pointer and default options 34 ImageRef(MagickCore::Image *image_); 35 36 // Destroy image and options 37 ~ImageRef(void); 38 39 // Decreases reference count and return the new count 40 size_t decrease(); 41 42 // Retrieve image from reference 43 MagickCore::Image *&image(void); 44 45 // Increases reference count 46 void increase(); 47 48 // Returns true if the reference count is more than one 49 bool isShared(); 50 51 // Retrieve Options from reference 52 void options(Options *options_); 53 Options *options(void); 54 55 // Tries to replaces the images with the specified image, returns 56 // a new instance when the current image is shared. 57 static ImageRef *replaceImage(ImageRef *imgRef, 58 MagickCore::Image *replacement_); 59 60 // Image signature. Set force_ to true in order to re-calculate 61 // the signature regardless of whether the image data has been 62 // modified. 63 std::string signature(const bool force_=false); 64 65 private: 66 67 // Construct with an image pointer and options 68 ImageRef(MagickCore::Image *image_,const Options *options_); 69 70 // Copy constructor and assignment are not supported 71 ImageRef(const ImageRef&); 72 73 ImageRef& operator=(const ImageRef&); 74 75 MagickCore::Image *_image; // ImageMagick Image 76 MutexLock _mutexLock; // Mutex lock 77 Options *_options; // User-specified options 78 ::ssize_t _refCount; // Reference count 79 }; 80 81 } // end of namespace Magick 82 83 #endif // Magick_ImageRef_header