~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to Magick++/lib/ImageRef.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This may look like C code, but it is really -*- C++ -*-
 
2
//
 
3
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
 
4
//
 
5
// Implementation of ImageRef
 
6
//
 
7
// This is an internal implementation class.
 
8
//
 
9
 
 
10
#define MAGICK_IMPLEMENTATION
 
11
 
 
12
#include "Magick++/ImageRef.h"
 
13
#include "Magick++/Exception.h"
 
14
#include "Magick++/Options.h"
 
15
 
 
16
// Construct with an image and default options
 
17
Magick::ImageRef::ImageRef ( MagickLib::Image * image_ )
 
18
  : _image(image_),
 
19
    _options(new Options),
 
20
    _id(-1),
 
21
    _refCount(1),
 
22
    _mutexLock()
 
23
{
 
24
}
 
25
 
 
26
// Construct with an image and options
 
27
// Inserts Image* in image, but copies Options into image.
 
28
Magick::ImageRef::ImageRef ( MagickLib::Image * image_,
 
29
                             const Options * options_ )
 
30
  : _image(image_),
 
31
    _options(0),
 
32
    _id(-1),
 
33
    _refCount(1),
 
34
    _mutexLock()
 
35
{
 
36
  _options = new Options( *options_ );
 
37
}
 
38
 
 
39
// Default constructor
 
40
Magick::ImageRef::ImageRef ( void )
 
41
  : _image(0),
 
42
    _options(new Options),
 
43
    _id(-1),
 
44
    _refCount(1),
 
45
    _mutexLock()
 
46
{
 
47
  // Allocate default image
 
48
  _image = AllocateImage( _options->imageInfo() );
 
49
 
 
50
  // Test for error and throw exception (like throwImageException())
 
51
  throwException(_image->exception);
 
52
}
 
53
 
 
54
// Destructor
 
55
Magick::ImageRef::~ImageRef( void )
 
56
{
 
57
  // Unregister image (if still registered)
 
58
  if( _id > -1 )
 
59
    {
 
60
      DeleteMagickRegistry( _id );
 
61
      _id=-1;
 
62
    }
 
63
 
 
64
  // Deallocate image
 
65
  if ( _image )
 
66
    {
 
67
      DestroyImageList( _image );
 
68
      _image = 0;
 
69
    }
 
70
 
 
71
  // Deallocate image options
 
72
  delete _options;
 
73
  _options = 0;
 
74
}
 
75
 
 
76
// Assign image to reference
 
77
void Magick::ImageRef::image ( MagickLib::Image * image_ )
 
78
{
 
79
  if(_image)
 
80
    DestroyImageList( _image );
 
81
  _image = image_;
 
82
}
 
83
 
 
84
// Assign options to reference
 
85
void  Magick::ImageRef::options ( Magick::Options * options_ )
 
86
{
 
87
  delete _options;
 
88
  _options = options_;
 
89
}
 
90
 
 
91
// Assign registration id to reference
 
92
void Magick::ImageRef::id ( const long id_ )
 
93
{
 
94
  if( _id > -1 )
 
95
    DeleteMagickRegistry( _id );
 
96
  _id = id_;
 
97
}