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 _image = AcquireImage( _options->imageInfo() );
51 // Test for error and throw exception (like throwImageException())
52 throwException(_image->exception);
56 Magick::ImageRef::~ImageRef( void )
58 // Unregister image (if still registered)
61 char id[MaxTextExtent];
62 sprintf(id,"%.20g",(double) _id);
63 DeleteImageRegistry( id );
70 DestroyImageList( _image );
74 // Deallocate image options
79 // Assign image to reference
80 void Magick::ImageRef::image ( MagickCore::Image * image_ )
83 DestroyImageList( _image );
87 // Assign options to reference
88 void Magick::ImageRef::options ( Magick::Options * options_ )
94 // Assign registration id to reference
95 void Magick::ImageRef::id ( const ssize_t id_ )
99 char id[MaxTextExtent];
100 sprintf(id,"%.20g",(double) _id);
101 DeleteImageRegistry( id );