Magick++ 7.1.1
Loading...
Searching...
No Matches
Magick::ImageRef Class Reference
Collaboration diagram for Magick::ImageRef:

Public Member Functions

 ImageRef (MagickCore::Image *image_)
 
size_t decrease ()
 
MagickCore::Image *& image (void)
 
void increase ()
 
bool isShared ()
 
void options (Options *options_)
 
Optionsoptions (void)
 
std::string signature (const bool force_=false)
 

Static Public Member Functions

static ImageRefreplaceImage (ImageRef *imgRef, MagickCore::Image *replacement_)
 

Private Member Functions

 ImageRef (MagickCore::Image *image_, const Options *options_)
 
 ImageRef (const ImageRef &)
 
ImageRefoperator= (const ImageRef &)
 

Private Attributes

MagickCore::Image * _image
 
MutexLock _mutexLock
 
Options_options
 
::ssize_t _refCount
 

Detailed Description

Definition at line 28 of file ImageRef.h.

Constructor & Destructor Documentation

◆ ImageRef() [1/3]

Magick::ImageRef::ImageRef ( void  )

Definition at line 20 of file ImageRef.cpp.

21 : _image(0),
22 _mutexLock(),
23 _options(new Options),
24 _refCount(1)
25{
26 GetPPException;
27 _image=AcquireImage(_options->imageInfo(),exceptionInfo);
28 ThrowPPException(false);
29}

◆ ImageRef() [2/3]

Magick::ImageRef::ImageRef ( MagickCore::Image *  image_)

Definition at line 31 of file ImageRef.cpp.

32 : _image(image_),
33 _mutexLock(),
34 _options(new Options),
35 _refCount(1)
36{
37}

◆ ~ImageRef()

Magick::ImageRef::~ImageRef ( void  )

Definition at line 39 of file ImageRef.cpp.

40{
41 // Deallocate image
42 if (_image != (MagickCore::Image*) NULL)
43 _image=DestroyImageList(_image);
44
45 // Deallocate image options
46 delete _options;
47 _options=(Options *) NULL;
48}

◆ ImageRef() [3/3]

Magick::ImageRef::ImageRef ( MagickCore::Image *  image_,
const Options options_ 
)
private

Definition at line 150 of file ImageRef.cpp.

151 : _image(image_),
152 _mutexLock(),
153 _options(0),
154 _refCount(1)
155{
156 _options=new Options(*options_);
157}

Member Function Documentation

◆ decrease()

size_t Magick::ImageRef::decrease ( )

Definition at line 50 of file ImageRef.cpp.

51{
52 size_t
53 count;
54
55 _mutexLock.lock();
56 if (_refCount == 0)
57 {
58 _mutexLock.unlock();
59 throwExceptionExplicit(MagickCore::OptionError,
60 "Invalid call to decrease");
61 return(0);
62 }
63 count=(size_t) (--_refCount);
64 _mutexLock.unlock();
65 return(count);
66}

◆ image()

MagickCore::Image *& Magick::ImageRef::image ( void  )

Definition at line 68 of file ImageRef.cpp.

69{
70 return(_image);
71}

◆ increase()

void Magick::ImageRef::increase ( )

Definition at line 73 of file ImageRef.cpp.

74{
75 _mutexLock.lock();
76 _refCount++;
77 _mutexLock.unlock();
78}

◆ isShared()

bool Magick::ImageRef::isShared ( )

Definition at line 80 of file ImageRef.cpp.

81{
82 bool
83 isShared;
84
85 _mutexLock.lock();
86 isShared=(_refCount > 1);
87 _mutexLock.unlock();
88 return(isShared);
89}

◆ options() [1/2]

void Magick::ImageRef::options ( Magick::Options options_)

Definition at line 91 of file ImageRef.cpp.

92{
93 delete _options;
94 _options=options_;
95}

◆ options() [2/2]

Magick::Options * Magick::ImageRef::options ( void  )

Definition at line 97 of file ImageRef.cpp.

98{
99 return(_options);
100}

◆ replaceImage()

Magick::ImageRef * Magick::ImageRef::replaceImage ( ImageRef imgRef,
MagickCore::Image *  replacement_ 
)
static

Definition at line 102 of file ImageRef.cpp.

104{
106 *instance;
107
108 imgRef->_mutexLock.lock();
109 if (imgRef->_refCount == 1)
110 {
111 // We can replace the image if we own it.
112 instance=imgRef;
113 if (imgRef->_image != (MagickCore::Image*) NULL)
114 (void) DestroyImageList(imgRef->_image);
115 imgRef->_image=replacement_;
116 imgRef->_mutexLock.unlock();
117 }
118 else
119 {
120 // We don't own the image, create a new ImageRef instance.
121 instance=new ImageRef(replacement_,imgRef->_options);
122 imgRef->_refCount--;
123 imgRef->_mutexLock.unlock();
124 }
125 return(instance);
126}

◆ signature()

std::string Magick::ImageRef::signature ( const bool  force_ = false)

Definition at line 128 of file ImageRef.cpp.

129{
130 const char
131 *property;
132
133 // Re-calculate image signature if necessary
134 GetPPException;
135 _mutexLock.lock();
136 property=(const char *) NULL;
137 if (!force_ && (_image->taint == MagickFalse))
138 property=GetImageProperty(_image,"Signature",exceptionInfo);
139 if (property == (const char *) NULL)
140 {
141 (void) SignatureImage(_image,exceptionInfo);
142 property=GetImageProperty(_image,"Signature",exceptionInfo);
143 }
144 _mutexLock.unlock();
145 ThrowPPException(true);
146
147 return(std::string(property));
148}

Member Data Documentation

◆ _image

MagickCore::Image* Magick::ImageRef::_image
private

Definition at line 77 of file ImageRef.h.

◆ _mutexLock

MutexLock Magick::ImageRef::_mutexLock
private

Definition at line 78 of file ImageRef.h.

◆ _options

Options* Magick::ImageRef::_options
private

Definition at line 79 of file ImageRef.h.

◆ _refCount

::ssize_t Magick::ImageRef::_refCount
private

Definition at line 80 of file ImageRef.h.


The documentation for this class was generated from the following files: