1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
5 // Implementation of ImageRef
7 // This is an internal implementation class.
10 #define MAGICKCORE_IMPLEMENTATION 1
11 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13 #include "Magick++/ImageRef.h"
14 #include "Magick++/Exception.h"
15 #include "Magick++/Options.h"
17 // Construct with an image and default options
18 Magick::ImageRef::ImageRef ( MagickCore::Image * image_ )
20 _options(new Options),
27 // Construct with an image and options
28 // Inserts Image* in image, but copies Options into image.
29 Magick::ImageRef::ImageRef ( MagickCore::Image * image_,
30 const Options * options_ )
37 _options = new Options( *options_ );
40 // Default constructor
41 Magick::ImageRef::ImageRef ( void )
43 _options(new Options),
48 // Allocate default image
49 ExceptionInfo exceptionInfo;
50 GetExceptionInfo( &exceptionInfo );
52 _image = AcquireImage( _options->imageInfo(), &exceptionInfo );
53 throwException( exceptionInfo );
54 (void) DestroyExceptionInfo( &exceptionInfo );
58 Magick::ImageRef::~ImageRef( void )
60 // Unregister image (if still registered)
63 char id[MaxTextExtent];
64 sprintf(id,"%.20g",(double) _id);
65 DeleteImageRegistry( id );
72 DestroyImageList( _image );
76 // Deallocate image options
81 // Assign image to reference
82 void Magick::ImageRef::image ( MagickCore::Image * image_ )
85 DestroyImageList( _image );
89 // Assign options to reference
90 void Magick::ImageRef::options ( Magick::Options * options_ )
96 // Assign registration id to reference
97 void Magick::ImageRef::id ( const ssize_t id_ )
101 char id[MaxTextExtent];
102 sprintf(id,"%.20g",(double) _id);
103 DeleteImageRegistry( id );