9#define MAGICKCORE_IMPLEMENTATION 1
10#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12#include "Magick++/Include.h"
13#include "Magick++/Blob.h"
14#include "Magick++/BlobRef.h"
18Magick::Blob::Blob(
void)
19 : _blobRef(new Magick::BlobRef(0,0))
23Magick::Blob::Blob(
const void* data_,
const size_t length_)
24 : _blobRef(new Magick::BlobRef(data_,length_))
29 : _blobRef(blob_._blobRef)
32 Lock lock(&_blobRef->_mutexLock);
33 ++_blobRef->_refCount;
40 Lock lock(&_blobRef->_mutexLock);
41 if (--_blobRef->_refCount == 0)
53Magick::Blob& Magick::Blob::operator=(
const Magick::Blob& blob_)
61 Lock lock(&blob_._blobRef->_mutexLock);
62 ++blob_._blobRef->_refCount;
66 Lock lock(&_blobRef->_mutexLock);
67 if (--_blobRef->_refCount == 0)
74 _blobRef=blob_._blobRef;
79void Magick::Blob::base64(
const std::string base64_)
87 decoded=Base64Decode(base64_.c_str(),&length);
89 updateNoCopy(
static_cast<void*
>(decoded),length,
90 Magick::Blob::MallocAllocator);
93std::string Magick::Blob::base64(
void)
105 encoded=Base64Encode(
static_cast<const unsigned char*
>(data()),length(),
110 result=std::string(encoded,encoded_length);
111 encoded=(
char *) RelinquishMagickMemory(encoded);
115 return(std::string());
118const void* Magick::Blob::data(
void)
const
120 return(_blobRef->_data);
123size_t Magick::Blob::length(
void)
const
125 return(_blobRef->_length);
128void Magick::Blob::update(
const void* data_,
const size_t length_)
135 Lock lock( &_blobRef->_mutexLock );
136 if (--_blobRef->_refCount == 0)
145 _blobRef=
new Magick::BlobRef(data_,length_);
148void Magick::Blob::updateNoCopy(
void* data_,
const size_t length_,
149 Magick::Blob::Allocator allocator_)
156 Lock lock(&_blobRef->_mutexLock);
157 if (--_blobRef->_refCount == 0)
166 _blobRef=
new Magick::BlobRef(0,0);
167 _blobRef->_data=data_;
168 _blobRef->_length=length_;
169 _blobRef->_allocator=allocator_;