[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: |
Tue, 05 Aug 2008 20:47:42 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 08/08/05 20:47:42
Modified files:
cvd/internal : load_and_save.h
cvd/internal/io: tiff.h
pnm_src : tiff.cxx
Log message:
Make the new IO system work on SubImages. The interface now reads 1
line at
a time. If this turns out to be a bottleneck, then the interface can be
expanded to take a number of lines and a stride.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/load_and_save.h?cvsroot=libcvd&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/io/tiff.h?cvsroot=libcvd&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/libcvd/pnm_src/tiff.cxx?cvsroot=libcvd&r1=1.11&r2=1.12
Patches:
Index: cvd/internal/load_and_save.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/load_and_save.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- cvd/internal/load_and_save.h 5 Aug 2008 02:12:45 -0000 1.13
+++ cvd/internal/load_and_save.h 5 Aug 2008 20:47:41 -0000 1.14
@@ -21,8 +21,6 @@
#ifndef CVD_LOAD_AND_SAVE_H
#define CVD_LOAD_AND_SAVE_H
-#include <cvd/internal/simple_vector.h>
-
#include <cvd/exceptions.h>
#include <cvd/image_convert.h>
#include <cvd/internal/convert_pixel_types.h>
@@ -157,7 +155,7 @@
// string datatype() Stringified name of datatype on disk
// string name() Name of the reader (JPEG, TIFF, etc)
// ImageRef size() size()
- // void get_raw_pixel_lines(T, int nlines) Where T is available
for everything in Types
+ // void get_raw_pixel_line(T) Where T is available for
everything in Types
// Constructor accepting istream;
@@ -178,23 +176,24 @@
// is performed.
template<class PixelType, class DiskPixelType, class
ImageLoader> struct read_and_maybe_process
{
- static void exec(BasicImage<PixelType>& im,
ImageLoader& r)
+ static void exec(SubImage<PixelType>& im, ImageLoader&
r)
{
- simple_vector<DiskPixelType> rowbuf(r.size().x);
+ Image<DiskPixelType>
rowbuf(ImageRef(r.size().x, 0));
for(int row = 0; row < r.size().y; row++)
{
- r.get_raw_pixel_lines(&rowbuf[0], 1);
- Pixel::ConvertPixels<DiskPixelType,
PixelType>::convert(&rowbuf[0], im[row], r.size().x);
+ r.get_raw_pixel_line(rowbuf.data());
+ Pixel::ConvertPixels<DiskPixelType,
PixelType>::convert(rowbuf.data(), im[row], r.size().x);
}
}
};
template<class PixelType, class ImageLoader> struct
read_and_maybe_process<PixelType, PixelType, ImageLoader>
{
- static void exec(BasicImage<PixelType>& im,
ImageLoader& r)
+ static void exec(SubImage<PixelType>& im, ImageLoader&
r)
{
- r.get_raw_pixel_lines(im.data(), r.size().y);
+ for(int row = 0; row < r.size().y; row++)
+ r.get_raw_pixel_line(im[row]);
}
};
@@ -205,7 +204,7 @@
//
template<class PixelType, class ImageLoader, class List >
struct Reader
{
- static void read(BasicImage<PixelType>& im,
ImageLoader& r)
+ static void read(SubImage<PixelType>& im, ImageLoader&
r)
{
if(r.datatype() == PNM::type_name<typename
List::Type>::name())
{
@@ -218,7 +217,7 @@
template<class PixelType, class ImageLoader> struct
Reader<PixelType, ImageLoader, Head>
{
- static void read(BasicImage<PixelType>&, ImageLoader& r)
+ static void read(SubImage<PixelType>&, ImageLoader& r)
{
throw
Exceptions::Image_IO::UnsupportedImageSubType(r.name(), r.datatype() + " not
yet supported");
}
@@ -230,12 +229,12 @@
// Driver functions for loading images.
//
- template<class T, class ImageLoader> void
readImage(BasicImage<T>& im, ImageLoader& r)
+ template<class T, class ImageLoader> void
readImage(SubImage<T>& im, ImageLoader& r)
{
Reader<T, ImageLoader, typename
ImageLoader::Types>::read(im, r);
}
- template <class T, class ImageLoader> void
readImage(BasicImage<T>& im, std::istream& in)
+ template <class T, class ImageLoader> void
readImage(SubImage<T>& im, std::istream& in)
{
ImageLoader loader(in);
ImageRef size = loader.size();
@@ -278,7 +277,7 @@
static void write(std::ostream& os, const
SubImage<Pixel>& im)
{
ImageWriter w(os, im.size(),
CVD::PNM::type_name<OutgoingPixel>::name());
- simple_vector<OutgoingPixel> row(im.size().x);
+ Image<OutgoingPixel> row(ImageRef(im.size().x,
0));
for(int r=0; r < im.size().y; r++)
{
Index: cvd/internal/io/tiff.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/io/tiff.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- cvd/internal/io/tiff.h 5 Aug 2008 02:12:45 -0000 1.7
+++ cvd/internal/io/tiff.h 5 Aug 2008 20:47:41 -0000 1.8
@@ -51,21 +51,21 @@
ImageRef size();
- void get_raw_pixel_lines(bool*, unsigned long nlines);
- void get_raw_pixel_lines(unsigned char*, unsigned long
nlines);
- void get_raw_pixel_lines(unsigned short*, unsigned long
nlines);
- void get_raw_pixel_lines(float*, unsigned long nlines);
- void get_raw_pixel_lines(double*, unsigned long nlines);
-
- void get_raw_pixel_lines(Rgb<unsigned char>*, unsigned
long nlines);
- void get_raw_pixel_lines(Rgb<unsigned short>*, unsigned
long nlines);
- void get_raw_pixel_lines(Rgb<float>*, unsigned long
nlines);
- void get_raw_pixel_lines(Rgb<double>*, unsigned long
nlines);
-
- void get_raw_pixel_lines(Rgba<unsigned char>*, unsigned
long nlines);
- void get_raw_pixel_lines(Rgba<unsigned short>*,
unsigned long nlines);
- void get_raw_pixel_lines(Rgba<float>*, unsigned long
nlines);
- void get_raw_pixel_lines(Rgba<double>*, unsigned long
nlines);
+ void get_raw_pixel_line(bool*);
+ void get_raw_pixel_line(unsigned char*);
+ void get_raw_pixel_line(unsigned short*);
+ void get_raw_pixel_line(float*);
+ void get_raw_pixel_line(double*);
+
+ void get_raw_pixel_line(Rgb<unsigned char>*);
+ void get_raw_pixel_line(Rgb<unsigned short>*);
+ void get_raw_pixel_line(Rgb<float>*);
+ void get_raw_pixel_line(Rgb<double>*);
+
+ void get_raw_pixel_line(Rgba<unsigned char>*);
+ void get_raw_pixel_line(Rgba<unsigned short>*);
+ void get_raw_pixel_line(Rgba<float>*);
+ void get_raw_pixel_line(Rgba<double>*);
std::string datatype();
std::string name();
Index: pnm_src/tiff.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/pnm_src/tiff.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- pnm_src/tiff.cxx 2 Aug 2008 01:40:07 -0000 1.11
+++ pnm_src/tiff.cxx 5 Aug 2008 20:47:42 -0000 1.12
@@ -43,8 +43,8 @@
~TIFFPimpl();
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);
+ template<class C> void get_raw_pixel_line(C* data);
+ void get_raw_pixel_line(bool* data);
private:
istream& i;
@@ -145,18 +145,18 @@
-template<class T> void TIFFPimpl::get_raw_pixel_lines(T* d, unsigned long
nlines)
+template<class T> void TIFFPimpl::get_raw_pixel_line(T* d)
{
if(datatype() != PNM::type_name<T>::name())
throw ReadTypeMismatch(datatype(), PNM::type_name<T>::name());
- if(row+nlines > (unsigned long)my_size.y)
+ if(row > (unsigned long)my_size.y)
throw InternalLibraryError("CVD", "Read past end of image.");
if(use_cooked_rgba_interface)
{
uint32* raster = &raster_data[row*my_size.x];
- uint32* end = raster + nlines * my_size.x;
+ uint32* end = raster + my_size.x;
//We will only ever get here if the type is Rgba
Rgba<unsigned char>* data = reinterpret_cast<Rgba<unsigned
char>* >(d);
@@ -169,28 +169,25 @@
data->alpha = TIFFGetA(*raster);
}
- row += nlines;
+ row ++;
}
else
{
- for(unsigned long i=0; i < nlines; i++, row++, d+=my_size.x)
- {
if(TIFFReadScanline(tif, (void*)d, row) == -1)
throw MalformedImage(error_msg);
if(inverted_grey)
attempt_invert(d, my_size.x);
- }
+
+ row++;
}
}
-void TIFFPimpl::get_raw_pixel_lines(bool* d, unsigned long nlines)
+void TIFFPimpl::get_raw_pixel_line(bool* d)
{
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);
@@ -200,7 +197,8 @@
if(inverted_grey)
invert(d, my_size.x);
- }
+
+ row++;
}
string TIFFPimpl::datatype()
@@ -389,7 +387,7 @@
};
//Mechanically generate the pixel reading calls.
-#define GEN1(X) void tiff_reader::get_raw_pixel_lines(X*d, unsigned long
n){t->get_raw_pixel_lines(d, n);}
+#define GEN1(X) void
tiff_reader::get_raw_pixel_line(X*d){t->get_raw_pixel_line(d);}
#define GEN3(X) GEN1(X) GEN1(Rgb<X>) GEN1(Rgba<X>)
GEN1(bool)