From: dirk Date: Thu, 18 Dec 2014 09:20:30 +0000 (+0000) Subject: Added new constructor with size and imageSpec to Image class of Magick++. X-Git-Tag: 7.0.1-0~1601 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40b3ec0ac359dc0c09d0a1bc28b809bb859cada2;p=imagemagick Added new constructor with size and imageSpec to Image class of Magick++. Added read method with size and color to Image class of Magick++. --- diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index 10228d336..54b6a84cb 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -183,17 +183,28 @@ Magick::Image::Image(const Blob &blob_,const Geometry &size_, Magick::Image::Image(const Geometry &size_,const Color &color_) : _imgRef(new ImageRef) { - // xc: prefix specifies an X11 color string - std::string imageSpec("xc:"); - imageSpec+=color_; - try { - // Set image size - size(size_); + read(size_,color_); + } + catch(const Warning &/*warning_*/) + { + // FIXME: need a way to report warnings in constructor + } + catch(const Error & /*error_*/) + { + // Release resources + delete _imgRef; + throw; + } +} - // Initialize, Allocate and Read images - read(imageSpec); +Magick::Image::Image(const Geometry &size_,const std::string &imageSpec_) + : _imgRef(new ImageRef) +{ + try + { + read(size_,imageSpec_); } catch(const Warning &/*warning_*/) { @@ -3887,6 +3898,14 @@ void Magick::Image::read(const Blob &blob_,const Geometry &size_, read(blob_); } +void Magick::Image::read(const Geometry &size_,const Color &color_) +{ + // xc: prefix specifies an X11 color string + std::string imageSpec("xc:"); + imageSpec+=color_; + read(size_,imageSpec); +} + void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_) { size(size_); diff --git a/Magick++/lib/Magick++/Image.h b/Magick++/lib/Magick++/Image.h index f0a23686d..33df7e70b 100644 --- a/Magick++/lib/Magick++/Image.h +++ b/Magick++/lib/Magick++/Image.h @@ -76,6 +76,9 @@ namespace Magick // Construct a blank image canvas of specified size and color Image(const Geometry &size_,const Color &color_); + // Construct image of specified size from image file or image specification + Image(const Geometry &size_,const std::string &imageSpec_); + // Copy constructor Image(const Image &image_); @@ -1171,6 +1174,9 @@ namespace Magick void read(const Blob &blob_,const Geometry &size_, const std::string &magick_); + // Read a blank image canvas of specified size and color + void read(const Geometry &size_,const Color &color_); + // Read single image frame of specified size into current object void read(const Geometry &size_,const std::string &imageSpec_);