libcvd-members
[Top][All Lists]
Advanced

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

[Libcvd-members] libcvd/cvd/internal pixel_traits.h io/bmp.h


From: Ethan Eade
Subject: [Libcvd-members] libcvd/cvd/internal pixel_traits.h io/bmp.h
Date: Tue, 16 May 2006 13:24:30 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Branch:         
Changes by:     Ethan Eade <address@hidden>     06/05/16 13:24:29

Modified files:
        cvd/internal   : pixel_traits.h 
        cvd/internal/io: bmp.h 

Log message:
        Whitespace changes in pixel_traits.h, use std::vector instead of arrays 
in
        BMP code.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/libcvd/cvd/internal/pixel_traits.h.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/libcvd/libcvd/cvd/internal/io/bmp.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: libcvd/cvd/internal/io/bmp.h
diff -u libcvd/cvd/internal/io/bmp.h:1.3 libcvd/cvd/internal/io/bmp.h:1.4
--- libcvd/cvd/internal/io/bmp.h:1.3    Wed Dec  7 14:45:19 2005
+++ libcvd/cvd/internal/io/bmp.h        Tue May 16 13:24:29 2006
@@ -24,6 +24,7 @@
 #include <iostream>
 #include <string>
 #include <memory>
+#include <vector>
 
 #include <cvd/image.h>
 #include <cvd/byte.h>
@@ -39,35 +40,35 @@
 
     template <class T> struct BMPReader<T,1> {
       static void read(Image<T>& im, std::istream& in) {
-       std::auto_ptr<Rgb<byte> > palette(new Rgb<byte>[256]);
+       std::vector<Rgb<byte> > palette(256);
        bool notgray = false;
        for (int i=0; i<256; i++) {
          byte buf[4];
          in.read((char*)buf,4);
-         palette.get()[i].red = buf[2];
-         palette.get()[i].green = buf[1];
-         palette.get()[i].blue = buf[0];
+         palette[i].red = buf[2];
+         palette[i].green = buf[1];
+         palette[i].blue = buf[0];
          if (buf[0] != i || buf[0] != buf[1] || buf[1] != buf[2])
            notgray = true;
        }
        size_t rowSize = im.size().x;
        if (rowSize % 4)
          rowSize += 4 - (rowSize%4);
-       std::auto_ptr<byte> rowbuf(new byte[rowSize]);
+       std::vector<byte> rowbuf(rowSize);
        
        if (notgray) {
          std::cerr << "not gray" << std::endl;
-         std::auto_ptr<T> cvt(new T[256]);
-         Pixel::ConvertPixels<Rgb<byte>,T>::convert(palette.get(), cvt.get(), 
256);
+         std::vector<T> cvt(256);
+         Pixel::ConvertPixels<Rgb<byte>,T>::convert(&palette[0], &cvt[0], 256);
          for (int r=im.size().y-1; r>=0; r--) {
-           in.read((char*)rowbuf.get(), rowSize);
+           in.read((char*)&rowbuf[0], rowSize);
            for (int c=0; c<im.size().x; c++)
-             im[r][c] = cvt.get()[rowbuf.get()[c]];
+             im[r][c] = cvt[rowbuf[c]];
          } 
        } else {          
          for (int r=im.size().y-1; r>=0; r--) {
-           in.read((char*)rowbuf.get(), rowSize);
-           Pixel::ConvertPixels<byte,T>::convert(rowbuf.get(), im[r], 
im.size().x);
+           in.read((char*)&rowbuf[0], rowSize);
+           Pixel::ConvertPixels<byte,T>::convert(&rowbuf[0], im[r], 
im.size().x);
          }
        }
       }
@@ -77,15 +78,15 @@
        size_t rowSize = im.size().x*3;
        if (rowSize % 4)
          rowSize += 4 - (rowSize%4);
-       std::auto_ptr<byte> rowbuf(new byte[rowSize]);
+       std::vector<byte> rowbuf(rowSize);
        for (int r=im.size().y-1; r>=0; r--) {
-         in.read((char*)rowbuf.get(), rowSize);
+         in.read((char*)&rowbuf[0], rowSize);
          for (int c=0; c<im.size().x*3; c+=3) {
-           byte tmp = rowbuf.get()[c];
-           rowbuf.get()[c] = rowbuf.get()[c+2];
-           rowbuf.get()[c+2] = tmp;
+           byte tmp = rowbuf[c];
+           rowbuf[c] = rowbuf[c+2];
+           rowbuf[c+2] = tmp;
          }
-         Pixel::ConvertPixels<Rgb<byte>, T>::convert((Rgb<byte>*)rowbuf.get(), 
im[r], im.size().x);
+         Pixel::ConvertPixels<Rgb<byte>, T>::convert((Rgb<byte>*)&rowbuf[0], 
im[r], im.size().x);
        }
       }
     };
@@ -125,10 +126,10 @@
        int rowSize = im.size().x;
        if (rowSize % 4)
          rowSize += 4 - (rowSize % 4);
-       std::auto_ptr<byte> rowbuf(new byte[rowSize]);
+       std::vector<byte> rowbuf(rowSize);
        for (int r=im.size().y-1; r>=0; r--) {
-         Pixel::ConvertPixels<T,byte>::convert(im[r], rowbuf.get(), 
im.size().x);
-         out.write((const char*)rowbuf.get(), rowSize);
+         Pixel::ConvertPixels<T,byte>::convert(im[r], &rowbuf[0], im.size().x);
+         out.write((const char*)&rowbuf[0], rowSize);
        }
       }
     };
@@ -151,15 +152,15 @@
        int rowSize = im.size().x*3;
        if (rowSize % 4)
          rowSize += 4 - (rowSize % 4);
-       std::auto_ptr<byte> rowbuf(new byte[rowSize]);
+       std::vector<byte> rowbuf(rowSize);
        for (int r=im.size().y-1; r>=0; r--) {
-         Pixel::ConvertPixels<T,Rgb<byte> >::convert(im[r], 
(Rgb<byte>*)rowbuf.get(), im.size().x);
+         Pixel::ConvertPixels<T,Rgb<byte> >::convert(im[r], 
(Rgb<byte>*)&rowbuf[0], im.size().x);
          for (int c=0; c<im.size().x*3; c+=3) {
-           byte tmp = rowbuf.get()[c];
-           rowbuf.get()[c] = rowbuf.get()[c+2];
-           rowbuf.get()[c+2] = tmp;
+           byte tmp = rowbuf[c];
+           rowbuf[c] = rowbuf[c+2];
+           rowbuf[c+2] = tmp;
          }
-         out.write((const char*)rowbuf.get(), rowSize);
+         out.write((const char*)&rowbuf[0], rowSize);
        }
       }
     };
Index: libcvd/cvd/internal/pixel_traits.h
diff -u libcvd/cvd/internal/pixel_traits.h:1.10 
libcvd/cvd/internal/pixel_traits.h:1.11
--- libcvd/cvd/internal/pixel_traits.h:1.10     Tue Apr  4 12:32:01 2006
+++ libcvd/cvd/internal/pixel_traits.h  Tue May 16 13:24:29 2006
@@ -181,16 +181,15 @@
                static const long double max_intensity; 
        };
 
-  template<int LIFT> struct traits<bool, LIFT>
-  {
-      typedef int wider_type;  // int holds a sum of many bools
-      typedef float float_type; // which floating point type can hold them?
-      static const bool integral = true; // bool is integral
-      static const bool is_signed = false; // bool is unsigned
-      static const int bits_used = 1; // only one bit
-      static const bool max_intensity= true;  // the 'high' value
-  };
-
+       template<int LIFT> struct traits<bool, LIFT>
+       {
+           typedef int wider_type;  // int holds a sum of many bools
+           typedef float float_type; // which floating point type can hold 
them?
+           static const bool integral = true; // bool is integral
+           static const bool is_signed = false; // bool is unsigned
+           static const int bits_used = 1; // only one bit
+           static const bool max_intensity= true;  // the 'high' value
+       };
 
 
 




reply via email to

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