mirror of
https://github.com/ImageMagick/ImageMagick.git
synced 2026-05-31 11:18:42 +02:00
Code cleanup.
This commit is contained in:
+63
-58
@@ -14,93 +14,98 @@
|
||||
#include "Magick++/Exception.h"
|
||||
#include "Magick++/Options.h"
|
||||
|
||||
// Construct with an image and default options
|
||||
Magick::ImageRef::ImageRef ( MagickCore::Image * image_ )
|
||||
: _image(image_),
|
||||
_options(new Options),
|
||||
_id(-1),
|
||||
_refCount(1),
|
||||
_mutexLock()
|
||||
{
|
||||
}
|
||||
|
||||
// Construct with an image and options
|
||||
// Inserts Image* in image, but copies Options into image.
|
||||
Magick::ImageRef::ImageRef ( MagickCore::Image * image_,
|
||||
const Options * options_ )
|
||||
: _image(image_),
|
||||
_options(0),
|
||||
_id(-1),
|
||||
_refCount(1),
|
||||
_mutexLock()
|
||||
{
|
||||
_options = new Options( *options_ );
|
||||
}
|
||||
|
||||
// Default constructor
|
||||
Magick::ImageRef::ImageRef ( void )
|
||||
Magick::ImageRef::ImageRef(void)
|
||||
: _image(0),
|
||||
_options(new Options),
|
||||
_id(-1),
|
||||
_refCount(1),
|
||||
_mutexLock()
|
||||
{
|
||||
// Allocate default image
|
||||
ExceptionInfo exceptionInfo;
|
||||
GetExceptionInfo( &exceptionInfo );
|
||||
|
||||
_image = AcquireImage( _options->imageInfo(), &exceptionInfo );
|
||||
throwException( exceptionInfo );
|
||||
(void) DestroyExceptionInfo( &exceptionInfo );
|
||||
GetPPException;
|
||||
_image=AcquireImage(_options->imageInfo(),&exceptionInfo);
|
||||
ThrowPPException;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Magick::ImageRef::~ImageRef( void )
|
||||
Magick::ImageRef::ImageRef(MagickCore::Image *image_)
|
||||
: _image(image_),
|
||||
_options(new Options),
|
||||
_id(-1),
|
||||
_refCount(1),
|
||||
_mutexLock()
|
||||
{
|
||||
}
|
||||
|
||||
Magick::ImageRef::ImageRef(MagickCore::Image *image_,const Options *options_)
|
||||
: _image(image_),
|
||||
_options(0),
|
||||
_id(-1),
|
||||
_refCount(1),
|
||||
_mutexLock()
|
||||
{
|
||||
_options=new Options(*options_);
|
||||
}
|
||||
|
||||
Magick::ImageRef::~ImageRef(void)
|
||||
{
|
||||
// Unregister image (if still registered)
|
||||
if( _id > -1 )
|
||||
if (_id > -1)
|
||||
{
|
||||
char id[MaxTextExtent];
|
||||
char
|
||||
id[MaxTextExtent];
|
||||
|
||||
sprintf(id,"%.20g",(double) _id);
|
||||
DeleteImageRegistry( id );
|
||||
DeleteImageRegistry(id);
|
||||
_id=-1;
|
||||
}
|
||||
|
||||
// Deallocate image
|
||||
if ( _image )
|
||||
if (_image != (MagickCore::Image*) NULL)
|
||||
{
|
||||
DestroyImageList( _image );
|
||||
_image = 0;
|
||||
DestroyImageList(_image);
|
||||
_image=(MagickCore::Image*) NULL;
|
||||
}
|
||||
|
||||
// Deallocate image options
|
||||
delete _options;
|
||||
_options = 0;
|
||||
_options=(Options *) NULL;
|
||||
}
|
||||
|
||||
// Assign image to reference
|
||||
void Magick::ImageRef::image ( MagickCore::Image * image_ )
|
||||
void Magick::ImageRef::id(const ssize_t id_)
|
||||
{
|
||||
if(_image)
|
||||
DestroyImageList( _image );
|
||||
_image = image_;
|
||||
if (_id > -1)
|
||||
{
|
||||
char
|
||||
id[MaxTextExtent];
|
||||
sprintf(id,"%.20g",(double) _id);
|
||||
DeleteImageRegistry(id);
|
||||
}
|
||||
_id=id_;
|
||||
}
|
||||
|
||||
// Assign options to reference
|
||||
void Magick::ImageRef::options ( Magick::Options * options_ )
|
||||
::ssize_t Magick::ImageRef::id(void) const
|
||||
{
|
||||
return(_id);
|
||||
}
|
||||
|
||||
MagickCore::Image *&Magick::ImageRef::image(void)
|
||||
{
|
||||
return(_image);
|
||||
}
|
||||
|
||||
void Magick::ImageRef::image(MagickCore::Image * image_)
|
||||
{
|
||||
if (_image != (MagickCore::Image*) NULL)
|
||||
DestroyImageList(_image);
|
||||
_image=image_;
|
||||
}
|
||||
|
||||
void Magick::ImageRef::options(Magick::Options *options_)
|
||||
{
|
||||
delete _options;
|
||||
_options = options_;
|
||||
_options=options_;
|
||||
}
|
||||
|
||||
// Assign registration id to reference
|
||||
void Magick::ImageRef::id ( const ssize_t id_ )
|
||||
Magick::Options *Magick::ImageRef::options(void)
|
||||
{
|
||||
if( _id > -1 )
|
||||
{
|
||||
char id[MaxTextExtent];
|
||||
sprintf(id,"%.20g",(double) _id);
|
||||
DeleteImageRegistry( id );
|
||||
}
|
||||
_id = id_;
|
||||
return(_options);
|
||||
}
|
||||
|
||||
@@ -21,60 +21,47 @@ namespace Magick
|
||||
//
|
||||
// Reference counted access to Image *
|
||||
//
|
||||
class MagickPPExport ImageRef {
|
||||
friend class Image;
|
||||
class MagickPPExport ImageRef
|
||||
{
|
||||
friend class Image;
|
||||
|
||||
private:
|
||||
// Construct with an image pointer and default options
|
||||
ImageRef ( MagickCore::Image * image_ );
|
||||
// Construct with an image pointer and options
|
||||
ImageRef ( MagickCore::Image * image_, const Options * options_ );
|
||||
|
||||
// Construct with null image and default options
|
||||
ImageRef ( void );
|
||||
ImageRef(void);
|
||||
|
||||
// Construct with an image pointer and default options
|
||||
ImageRef(MagickCore::Image *image_);
|
||||
|
||||
// Construct with an image pointer and options
|
||||
ImageRef(MagickCore::Image *image_,const Options *options_);
|
||||
|
||||
// Destroy image and options
|
||||
~ImageRef ( void );
|
||||
~ImageRef(void);
|
||||
|
||||
// Copy constructor and assignment are not supported
|
||||
ImageRef(const ImageRef&);
|
||||
ImageRef& operator=(const ImageRef&);
|
||||
|
||||
void image ( MagickCore::Image * image_ );
|
||||
MagickCore::Image *& image ( void );
|
||||
|
||||
void options ( Options * options_ );
|
||||
Options * options ( void );
|
||||
|
||||
void id ( const ::ssize_t id_ );
|
||||
::ssize_t id ( void ) const;
|
||||
|
||||
MagickCore::Image * _image; // ImageMagick Image
|
||||
Options * _options; // User-specified options
|
||||
::ssize_t _id; // Registry ID (-1 if not registered)
|
||||
::ssize_t _refCount; // Reference count
|
||||
MutexLock _mutexLock;// Mutex lock
|
||||
// Retrieve registration id from reference
|
||||
void id(const ::ssize_t id_);
|
||||
::ssize_t id(void) const;
|
||||
|
||||
// Retrieve image from reference
|
||||
void image(MagickCore::Image *image_);
|
||||
MagickCore::Image *&image(void);
|
||||
|
||||
// Retrieve Options from reference
|
||||
void options(Options *options_);
|
||||
Options *options(void);
|
||||
|
||||
MagickCore::Image *_image; // ImageMagick Image
|
||||
Options *_options; // User-specified options
|
||||
::ssize_t _id; // Registry ID (-1 if not registered)
|
||||
::ssize_t _refCount; // Reference count
|
||||
MutexLock _mutexLock; // Mutex lock
|
||||
};
|
||||
|
||||
} // end of namespace Magick
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
|
||||
// Retrieve image from reference
|
||||
inline MagickCore::Image *& Magick::ImageRef::image ( void )
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
|
||||
// Retrieve Options from reference
|
||||
inline Magick::Options * Magick::ImageRef::options ( void )
|
||||
{
|
||||
return _options;
|
||||
}
|
||||
|
||||
// Retrieve registration id from reference
|
||||
inline ::ssize_t Magick::ImageRef::id ( void ) const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
#endif // Magick_ImageRef_header
|
||||
#endif // Magick_ImageRef_header
|
||||
Reference in New Issue
Block a user