]> granicus.if.org Git - imagemagick/commitdiff
Added new constructor with size and imageSpec to Image class of Magick++.
authordirk <dirk@git.imagemagick.org>
Thu, 18 Dec 2014 09:20:30 +0000 (09:20 +0000)
committerdirk <dirk@git.imagemagick.org>
Thu, 18 Dec 2014 09:20:30 +0000 (09:20 +0000)
Added read method with size and color to Image class of Magick++.

Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h

index 10228d3367c0cb70f92ae444671a7b0ee6a2e0fd..54b6a84cbebe992d714a5d6905bed6eda5467ebd 100644 (file)
@@ -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_);
index f0a23686d9f6e414b18d1a1f6acf0ddfa7249dee..33df7e70bf04fbd1c29c5c3719b443322e4c09d5 100644 (file)
@@ -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_);