[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd/internal io/bmp.h simple_vector.h
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd/cvd/internal io/bmp.h simple_vector.h |
Date: |
Fri, 29 Sep 2006 21:59:45 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 06/09/29 21:59:45
Modified files:
cvd/internal/io: bmp.h
Added files:
cvd/internal : simple_vector.h
Log message:
Replace std::vector with Internal::simple_vector, since std::vector does
funny things with bools. Only affected BMP, since PNG has
specializations
for bool, and the rest (incorrectly) use auto_ptr<T> to hold a T[].
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/simple_vector.h?cvsroot=libcvd&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/io/bmp.h?cvsroot=libcvd&r1=1.4&r2=1.5
Patches:
Index: io/bmp.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/io/bmp.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- io/bmp.h 16 May 2006 13:24:29 -0000 1.4
+++ io/bmp.h 29 Sep 2006 21:59:45 -0000 1.5
@@ -30,6 +30,7 @@
#include <cvd/byte.h>
#include <cvd/internal/convert_pixel_types.h>
#include <cvd/internal/load_and_save.h>
+#include <cvd/internal/simple_vector.h>
namespace CVD {
namespace BMP {
@@ -40,7 +41,7 @@
template <class T> struct BMPReader<T,1> {
static void read(Image<T>& im, std::istream& in) {
- std::vector<Rgb<byte> > palette(256);
+ Internal::simple_vector<Rgb<byte> > palette(256);
bool notgray = false;
for (int i=0; i<256; i++) {
byte buf[4];
@@ -54,11 +55,11 @@
size_t rowSize = im.size().x;
if (rowSize % 4)
rowSize += 4 - (rowSize%4);
- std::vector<byte> rowbuf(rowSize);
+ Internal::simple_vector<byte> rowbuf(rowSize);
if (notgray) {
std::cerr << "not gray" << std::endl;
- std::vector<T> cvt(256);
+ Internal::simple_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[0], rowSize);
@@ -78,7 +79,7 @@
size_t rowSize = im.size().x*3;
if (rowSize % 4)
rowSize += 4 - (rowSize%4);
- std::vector<byte> rowbuf(rowSize);
+ Internal::simple_vector<byte> rowbuf(rowSize);
for (int r=im.size().y-1; r>=0; r--) {
in.read((char*)&rowbuf[0], rowSize);
for (int c=0; c<im.size().x*3; c+=3) {
@@ -126,7 +127,7 @@
int rowSize = im.size().x;
if (rowSize % 4)
rowSize += 4 - (rowSize % 4);
- std::vector<byte> rowbuf(rowSize);
+ Internal::simple_vector<byte> rowbuf(rowSize);
for (int r=im.size().y-1; r>=0; r--) {
Pixel::ConvertPixels<T,byte>::convert(im[r], &rowbuf[0], im.size().x);
out.write((const char*)&rowbuf[0], rowSize);
@@ -152,7 +153,7 @@
int rowSize = im.size().x*3;
if (rowSize % 4)
rowSize += 4 - (rowSize % 4);
- std::vector<byte> rowbuf(rowSize);
+ Internal::simple_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[0], im.size().x);
for (int c=0; c<im.size().x*3; c+=3) {
Index: simple_vector.h
===================================================================
RCS file: simple_vector.h
diff -N simple_vector.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ simple_vector.h 29 Sep 2006 21:59:45 -0000 1.1
@@ -0,0 +1,37 @@
+#ifndef CVD_INTERNAL_SIMPLE_VECTOR_H
+#define CVD_INTERNAL_SIMPLE_VECTOR_H
+
+namespace CVD{
+namespace Internal{
+
+
+ template<class T> class simple_vector
+ {
+ private:
+ T* dat;
+
+ public:
+ simple_vector(size_t n)
+ :dat(new T[n])
+ {}
+
+ T* data()
+ {
+ return dat;
+ }
+
+ T& operator[](size_t n)
+ {
+ return dat[n];
+ }
+
+ ~simple_vector()
+ {
+ delete[] dat;
+ }
+ };
+
+
+}}
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd/cvd/internal io/bmp.h simple_vector.h,
Edward Rosten <=