Commit 78ba83c9 authored by dirk's avatar dirk

Fix cleanup of layer info.

git-svn-id: https://subversion.imagemagick.org/subversion/ImageMagick/branches/ImageMagick-6@14060 aa41f4f7-0bf4-0310-aa73-e5a19afd5a74
parent bbe7b10b
This diff is collapsed.
......@@ -38,7 +38,7 @@ Terms and Conditions for Use, Reproduction, and Distribution
The legally binding and authoritative terms and conditions for use, reproduction, and distribution of ImageMagick follow:
Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available.
Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available.
1. Definitions.
......
The author and maintainer of Magick++ is Bob Friesenhan
<bfriesen@simple.dallas.tx.us>.
Many thanks to John Cristy for developing the powerful ImageMagick
Many thanks to Cristy for developing the powerful ImageMagick
package that Magick++ is based on and for enhancing ImageMagick API
features in order to allow a cleaner implementation.
......
......@@ -1315,7 +1315,7 @@
* lib/Image.cpp:
(rotate): No longer accepts sharpen argument.
User must sharpen seperately if desired. This change is due to a
User must sharpen separately if desired. This change is due to a
similar change in ImageMagick 5.0.
(condense): Removed method.
(uncondense): Removed method.
......
......@@ -76,7 +76,7 @@ Magick++:
Professional
Release 6
Mac OS X GCC 2.95.2
10.1 PowerPC (apple gcc John Cristy
10.1 PowerPC (apple gcc Cristy
"Darwin" -926)
Please let me know if you have successfully built and executed Magick++
......
......@@ -3,7 +3,7 @@
// Copyright Bob Friesenhahn, 1999, 2000, 2002, 2003
//
// PerlMagick "piddle" demo re-implemented using Magick++ methods.
// The PerlMagick "piddle" demo is written by John Cristy
// The PerlMagick "piddle" demo is written by Cristy
//
#include <Magick++.h>
......@@ -80,9 +80,14 @@ int main( int /*argc*/, char ** argv)
//
// Draw line
//
drawList.push_back(DrawableStrokeColor("red"));
drawList.push_back(DrawableStrokeWidth(1));
drawList.push_back(DrawableLine(10,200, 20,190));
{
const double dash_array[] = {4.0, 3.0, 0.0};
drawList.push_back(DrawableDashArray(dash_array));
drawList.push_back(DrawableStrokeColor("red"));
drawList.push_back(DrawableStrokeWidth(1));
drawList.push_back(DrawableLine(10,200, 54,182));
drawList.push_back(DrawableDashArray((double *) 0));
}
//
// Draw arc within a circle.
......
......@@ -14,42 +14,34 @@
#include <string.h>
//
// Implementation of Magick::Blob
//
// Default constructor
Magick::Blob::Blob ( void )
: _blobRef(new Magick::BlobRef( 0, 0 ))
Magick::Blob::Blob(void)
: _blobRef(new Magick::BlobRef(0,0))
{
}
// Construct with data
Magick::Blob::Blob ( const void* data_, size_t length_ )
: _blobRef(new Magick::BlobRef( data_, length_ ))
Magick::Blob::Blob(const void* data_,size_t length_)
: _blobRef(new Magick::BlobRef(data_,length_))
{
}
// Copy constructor (reference counted)
Magick::Blob::Blob ( const Magick::Blob& blob_ )
Magick::Blob::Blob(const Magick::Blob& blob_)
: _blobRef(blob_._blobRef)
{
// Increase reference count
Lock( &_blobRef->_mutexLock );
Lock(&_blobRef->_mutexLock);
++_blobRef->_refCount;
}
// Destructor (reference counted)
Magick::Blob::~Blob ()
{
bool doDelete = false;
bool doDelete=false;
{
Lock( &_blobRef->_mutexLock );
if ( --_blobRef->_refCount == 0 )
doDelete = true;
Lock(&_blobRef->_mutexLock);
if (--_blobRef->_refCount == 0)
doDelete=true;
}
if ( doDelete )
if (doDelete)
{
// Delete old blob reference with associated data
delete _blobRef;
......@@ -57,113 +49,121 @@ Magick::Blob::~Blob ()
_blobRef=0;
}
// Assignment operator (reference counted)
Magick::Blob& Magick::Blob::operator= ( const Magick::Blob& blob_ )
Magick::Blob& Magick::Blob::operator=(const Magick::Blob& blob_)
{
if(this != &blob_)
bool
doDelete;
if (this != &blob_)
{
{
Lock( &blob_._blobRef->_mutexLock );
Lock(&blob_._blobRef->_mutexLock);
++blob_._blobRef->_refCount;
}
bool doDelete = false;
doDelete=false;
{
Lock( &_blobRef->_mutexLock );
if ( --_blobRef->_refCount == 0 )
doDelete = true;
Lock(&_blobRef->_mutexLock);
if (--_blobRef->_refCount == 0)
doDelete=true;
}
if ( doDelete )
if (doDelete)
{
delete _blobRef;
}
_blobRef = blob_._blobRef;
_blobRef=blob_._blobRef;
}
return *this;
return(*this);
}
// Update object contents from Base64-encoded string representation.
void Magick::Blob::base64 ( const std::string base64_ )
void Magick::Blob::base64(const std::string base64_)
{
size_t length;
size_t
length;
unsigned char *decoded =
Base64Decode( base64_.c_str(), &length );
unsigned char
*decoded;
if(decoded)
updateNoCopy( static_cast<void*>(decoded), length,
Magick::Blob::MallocAllocator );
decoded=Base64Decode(base64_.c_str(),&length);
if (decoded)
updateNoCopy(static_cast<void*>(decoded),length,
Magick::Blob::MallocAllocator);
}
// Return Base64-encoded string representation.
std::string Magick::Blob::base64 ( void )
std::string Magick::Blob::base64(void)
{
size_t encoded_length = 0;
char
*encoded;
size_t
encoded_length;
char *encoded =
Base64Encode(static_cast<const unsigned char*>(data()), length(), &encoded_length);
std::string
result;
if(encoded)
encoded_length=0;
encoded=Base64Encode(static_cast<const unsigned char*>(data()),length(),
&encoded_length);
if (encoded)
{
std::string result(encoded,encoded_length);
result=std::string(encoded,encoded_length);
encoded=(char *) RelinquishMagickMemory(encoded);
return result;
}
return std::string();
return(std::string());
}
const void* Magick::Blob::data(void) const
{
return(_blobRef->_data);
}
size_t Magick::Blob::length(void) const
{
return(_blobRef->_length);
}
// Update object contents, making a copy of the supplied data.
// Any existing data in the object is deallocated.
void Magick::Blob::update ( const void* data_, size_t length_ )
void Magick::Blob::update(const void* data_,size_t length_)
{
bool doDelete = false;
bool
doDelete;
doDelete=false;
{
Lock( &_blobRef->_mutexLock );
if ( --_blobRef->_refCount == 0 )
doDelete = true;
if (--_blobRef->_refCount == 0)
doDelete=true;
}
if ( doDelete )
if (doDelete)
{
// Delete old blob reference with associated data
delete _blobRef;
}
_blobRef = new Magick::BlobRef( data_, length_ );
_blobRef=new Magick::BlobRef(data_,length_);
}
// Update object contents, using supplied pointer directly (no copy)
// Any existing data in the object is deallocated. The user must
// ensure that the pointer supplied is not deleted or otherwise
// modified after it has been supplied to this method.
void Magick::Blob::updateNoCopy ( void* data_, size_t length_,
Magick::Blob::Allocator allocator_ )
void Magick::Blob::updateNoCopy(void* data_,size_t length_,
Magick::Blob::Allocator allocator_)
{
bool doDelete = false;
bool
doDelete;
doDelete=false;
{
Lock( &_blobRef->_mutexLock );
if ( --_blobRef->_refCount == 0 )
doDelete = true;
Lock(&_blobRef->_mutexLock);
if (--_blobRef->_refCount == 0)
doDelete=true;
}
if ( doDelete )
if (doDelete)
{
// Delete old blob reference with associated data
delete _blobRef;
}
_blobRef = new Magick::BlobRef( 0, 0 );
_blobRef->_data = data_;
_blobRef->_length = length_;
_blobRef->_allocator = allocator_;
}
// Obtain pointer to data
const void* Magick::Blob::data( void ) const
{
return _blobRef->_data;
}
// Obtain data length
size_t Magick::Blob::length( void ) const
{
return _blobRef->_length;
_blobRef=new Magick::BlobRef(0,0);
_blobRef->_data=data_;
_blobRef->_length=length_;
_blobRef->_allocator=allocator_;
}
......@@ -14,35 +14,29 @@
#include <string.h>
//
// Implementation of Magick::BlobRef
//
// Construct with data, making private copy of data
Magick::BlobRef::BlobRef ( const void* data_,
size_t length_ )
Magick::BlobRef::BlobRef(const void* data_,size_t length_)
: _data(0),
_length(length_),
_allocator(Magick::Blob::NewAllocator),
_refCount(1),
_mutexLock()
{
if( data_ )
if (data_)
{
_data = new unsigned char[length_];
memcpy( _data, data_, length_ );
_data=new unsigned char[length_];
memcpy(_data,data_,length_);
}
}
// Destructor (actually destroys data)
Magick::BlobRef::~BlobRef ( void )
Magick::BlobRef::~BlobRef(void)
{
if ( _allocator == Magick::Blob::NewAllocator )
if (_allocator == Magick::Blob::NewAllocator)
{
delete [] static_cast<unsigned char*>(_data);
delete[] static_cast<unsigned char*>(_data);
_data=0;
}
else if ( _allocator == Magick::Blob::MallocAllocator )
else if (_allocator == Magick::Blob::MallocAllocator)
{
_data=(void *) RelinquishMagickMemory(_data);
}
......
......@@ -14,109 +14,114 @@
using namespace std;
// Default constructor
Magick::CoderInfo::CoderInfo ( void )
Magick::CoderInfo::CoderInfo(void)
: _name(),
_description(),
_mimeType(),
_isReadable(false),
_isWritable(false),
_isMultiFrame(false)
{
}
// Copy constructor
Magick::CoderInfo::CoderInfo ( const Magick::CoderInfo &coder_ )
Magick::CoderInfo::CoderInfo(const Magick::CoderInfo &coder_)
{
_name = coder_._name;
_description = coder_._description;
_isReadable = coder_._isReadable;
_isWritable = coder_._isWritable;
_isMultiFrame = coder_._isMultiFrame;
_name=coder_._name;
_description=coder_._description;
_mimeType=coder_._mimeType;
_isReadable=coder_._isReadable;
_isWritable=coder_._isWritable;
_isMultiFrame=coder_._isMultiFrame;
}
Magick::CoderInfo::CoderInfo ( const std::string &name_ )
Magick::CoderInfo::CoderInfo(const std::string &name_)
: _name(),
_description(),
_mimeType(),
_isReadable(false),
_isWritable(false),
_isMultiFrame(false)
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
const Magick::MagickInfo *magickInfo = GetMagickInfo( name_.c_str(), &exceptionInfo );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
if( magickInfo == 0 )
ExceptionInfo
exceptionInfo;
const Magick::MagickInfo
*magickInfo;
GetExceptionInfo(&exceptionInfo);
magickInfo=GetMagickInfo(name_.c_str(),&exceptionInfo);
throwException(exceptionInfo);
(void) DestroyExceptionInfo(&exceptionInfo);
if (magickInfo == 0)
{
throwExceptionExplicit(OptionError, "Coder not found", name_.c_str() );
throwExceptionExplicit(OptionError,"Coder not found",name_.c_str());
}
else
{
_name = string(magickInfo->name);
_description = string(magickInfo->description);
_isReadable = ((magickInfo->decoder == 0) ? false : true);
_isWritable = ((magickInfo->encoder == 0) ? false : true);
_isMultiFrame = ((magickInfo->adjoin == 0) ? false : true);
_name=string(magickInfo->name);
_description=string(magickInfo->description);
_mimeType=string(magickInfo->mime_type ? magickInfo->mime_type : "");
_isReadable=((magickInfo->decoder == 0) ? false : true);
_isWritable=((magickInfo->encoder == 0) ? false : true);
_isMultiFrame=((magickInfo->adjoin == 0) ? false : true);
}
}
Magick::CoderInfo::~CoderInfo ( void )
Magick::CoderInfo::~CoderInfo(void)
{
// Nothing to do
}
// Format name
std::string Magick::CoderInfo::name( void ) const
Magick::CoderInfo& Magick::CoderInfo::operator=(const CoderInfo &coder_)
{
return _name;
// If not being set to ourself