[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/internal/load_and_save.h cvd/interna...
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd cvd/internal/load_and_save.h cvd/interna... |
Date: |
Sat, 02 Aug 2008 01:32:39 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 08/08/02 01:32:39
Modified files:
cvd/internal : load_and_save.h name_builtin_types.h
pnm_src : tiff.cxx
test : test_images.cxx
Log message:
Fixed TIFF bool loading.
TIFF loading now passes all visual tests in test_images.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/load_and_save.h?cvsroot=libcvd&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/name_builtin_types.h?cvsroot=libcvd&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/libcvd/pnm_src/tiff.cxx?cvsroot=libcvd&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/libcvd/test/test_images.cxx?cvsroot=libcvd&r1=1.9&r2=1.10
Patches:
Index: cvd/internal/load_and_save.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/load_and_save.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- cvd/internal/load_and_save.h 2 Aug 2008 00:17:19 -0000 1.9
+++ cvd/internal/load_and_save.h 2 Aug 2008 01:32:38 -0000 1.10
@@ -191,6 +191,12 @@
}
};
+
+ template<class C> std::string wtf()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+
////////////////////////////////////////////////////////////////////////////////
//
// Iterate over the typelist, and decide which type to load.
Index: cvd/internal/name_builtin_types.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/name_builtin_types.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cvd/internal/name_builtin_types.h 9 May 2005 11:54:59 -0000 1.3
+++ cvd/internal/name_builtin_types.h 2 Aug 2008 01:32:38 -0000 1.4
@@ -28,6 +28,7 @@
namespace PNM
{
template<class T> struct type_name{ static const std::string name(){
return"unknown"; }};
+ template<> struct type_name<bool>{static const std::string name(){
return "bool";}};
template<> struct type_name<char>{static const std::string name(){
return "char";}};
template<> struct type_name<signed char>{static const std::string
name(){ return "signed char";}};
template<> struct type_name<unsigned char>{static const std::string
name(){ return "unsigned char";}};
Index: pnm_src/tiff.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/pnm_src/tiff.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- pnm_src/tiff.cxx 2 Aug 2008 00:17:20 -0000 1.9
+++ pnm_src/tiff.cxx 2 Aug 2008 01:32:38 -0000 1.10
@@ -44,6 +44,7 @@
ImageRef size();
string datatype();
template<class C> void get_raw_pixel_lines(C* data, unsigned
long n);
+ void get_raw_pixel_lines(bool* data, unsigned long n);
private:
istream& i;
@@ -56,6 +57,7 @@
bool inverted_grey;
vector<uint32> raster_data;
+ vector<uint8> bool_rowbuf;
static tsize_t write(thandle_t vis, tdata_t data, tsize_t
count);
static tsize_t read(thandle_t vis, tdata_t data, tsize_t count);
@@ -182,6 +184,29 @@
}
}
+void TIFFPimpl::get_raw_pixel_lines(bool* d, unsigned long nlines)
+{
+ if(datatype() != PNM::type_name<bool>::name())
+ throw ReadTypeMismatch(datatype(),
PNM::type_name<bool>::name());
+
+ for(unsigned long i=0; i < nlines; i++, row++, d+=my_size.x)
+ {
+ if(TIFFReadScanline(tif, (void*)&bool_rowbuf[0], row) == -1)
+ throw MalformedImage(error_msg);
+
+ //Unpack the bools
+ for(int i=0; i < my_size.x ;i++)
+ d[i] = (bool_rowbuf[i/8] >> (7-i%8)) & 1;
+
+ if(inverted_grey)
+ invert(d, my_size.x);
+ }
+
+
+}
+
+
+
string TIFFPimpl::datatype()
{
return type;
@@ -300,6 +325,10 @@
inverted_grey=0;
}
+ if(type == "bool")
+ bool_rowbuf.resize((size().x + 7)/8);
+
+
if(use_cooked_rgba_interface)
{
Index: test/test_images.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/test/test_images.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- test/test_images.cxx 28 Nov 2005 18:42:17 -0000 1.9
+++ test/test_images.cxx 2 Aug 2008 01:32:39 -0000 1.10
@@ -109,6 +109,7 @@
for(int i=1; i <ac; i++)
{
+ loadsave_safe<bool>(av[i]);
loadsave_safe<unsigned char>(av[i]);
loadsave_safe<signed char>(av[i]);
loadsave_safe<short>(av[i]);