libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvdimage_io.h cvd_src/image_io.cc


From: Edward Rosten
Subject: [libcvd-members] libcvd cvdimage_io.h cvd_src/image_io.cc
Date: Mon, 05 Jun 2006 22:17:50 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        06/06/05 22:17:50

Modified files:
        cvd            : image_io.h 
        cvd_src        : image_io.cc 

Log message:
        string_to_image_type  now returns Unknown, but img_save still defaults
        to PNM. If you relied on string_to_image_type to return PNM by
        default, then your code will break.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/image_io.h?cvsroot=libcvd&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/image_io.cc?cvsroot=libcvd&r1=1.19&r2=1.20

Patches:
Index: cvd/image_io.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/image_io.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- cvd/image_io.h      9 Mar 2006 15:31:26 -0000       1.24
+++ cvd/image_io.h      5 Jun 2006 22:17:50 -0000       1.25
@@ -61,7 +61,9 @@
        {
                enum ImageType
                {
-                       PNM,
+                       Automatic= -2,
+                       Unknown = -1,
+                       PNM=0,
                        PS,
                        EPS,
                        BMP,
@@ -79,6 +81,10 @@
                /// Possible image types
                enum ImageType
                {
+                       /// Placeholder type telling @ref save_image to deduce 
the type from the filename
+                       Automatic,
+                       /// Unknown image type (can be returned by @ref 
string_to_image_type
+                       Unknown,
                        /// PNM image format (PBM, PGM or PPM). This is a raw 
image format.
                        PNM, 
                        /// JPEG image format. This is a compressed (lossy) 
image format, but defaults to 95% quality, which has very few compression 
artefacts. This image type is only present if libjpeg is available.
@@ -183,17 +189,25 @@
          }
        }
 
-       template<class PixelType> void img_save(const BasicImage<PixelType>& 
im, const std::string& name, ImageType::ImageType t)
+       template<class PixelType> void img_save(const BasicImage<PixelType>& 
im, const std::string& name, ImageType::ImageType t, ImageType::ImageType d = 
ImageType::PNM)
        {
          std::ofstream out(name.c_str(), std::ios::out|std::ios::binary);
          if(!out.good())
            throw Exceptions::Image_IO::OpenError(name, "for writing", errno);
+
+         if(t = ImageType::Automatic)
+         {
+               t = string_to_image_type(name);
+               if(t == ImageType::Unknown)
+                       t = d;
+         }
+
          img_save(im, out, t);
        }
 
        template<class PixelType> void img_save(const BasicImage<PixelType>& 
im, const std::string& name)
        {
-           img_save(im, name, string_to_image_type(name));
+           img_save(im, name, name, ImageType::Automatic);
        }
 
        
////////////////////////////////////////////////////////////////////////////////

Index: cvd_src/image_io.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/image_io.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- cvd_src/image_io.cc 13 Feb 2006 17:23:00 -0000      1.19
+++ cvd_src/image_io.cc 5 Jun 2006 22:17:50 -0000       1.20
@@ -108,8 +108,10 @@
                return  ImageType::EPS;
        else if (suffix == "bmp") 
                return  ImageType::BMP;
-       else 
+       else if (suffix == "pnm" || suffix == "ppm" || suffix == "pgm" || 
suffix == "pbm") 
                return  ImageType::PNM;
+       else
+               return ImageType::Unknown;
 }
 
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]