Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageFile.h
Go to the documentation of this file.
1 /* Import from Gabor API
2 
3 Copyright (c) 2002-3 Adriaan Tijsseling
4 
5 
6  All Rights Reserved
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 /*
23  Description: Abstract class for reading and storing images
24  Original Author: Mickael Pic
25  Modifications by: Adriaan Tijsseling (AGT)
26 */
27 
28 #ifndef __IMAGE_FILE_CLASS__
29 #define __IMAGE_FILE_CLASS__
30 
31 #include <iostream>
32 #include <fstream>
33 #include <string>
34 #include <math.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 
38 namespace celeste
39 {
40 enum
41 {
42  kChars = 0x01,
43  kFloats = 0x02,
44  kRGB = 0x04
45 };
46 
47 class ImageFile
48 {
49 public:
50 
51  ImageFile();
52  virtual ~ImageFile();
53 
54  // set or get width of image
55  inline void SetWidth( int w ) { mWidth = w; }
56  inline int GetWidth() { return mWidth; }
57 
58  // set or get height of image
59  inline void SetHeight( int h ){ mHeight = h; }
60  inline int GetHeight(){ return mHeight; }
61 
62  // set or get one single pixel
63  inline void SetPixel( int x, int y, unsigned char p ) { if ( mPixels != NULL ) mPixels[x][y] = p; }
64  unsigned char GetPixel( int x, int y );
65 
66  // set or get pixels
67  inline int*** GetRGBPixels( void ) { return mRGB; }
68  void SetPixels( float** );
69  float** GetPixels( void );
70 
71  // allocate pixelmap
72  void Allocate( int dataset );
73  void Deallocate();
74 
75  // read to or write image from file
76  virtual int Read( char* ) = 0;
77  virtual void Write( char* ) = 0;
78 
79 protected:
80 
81  int*** mRGB; // rgb pixels
82  unsigned char** mPixels; // pixel storage
83  float** mFloats; // converted to floats
84  int mWidth; // image width
85  int mHeight; // image height
86  bool mVerbosity; // verbosity level
87 
88  };
89 }//namespace
90 #endif
unsigned char ** mPixels
Definition: ImageFile.h:82
virtual ~ImageFile()
Definition: ImageFile.cpp:43
virtual int Read(char *)=0
void SetWidth(int w)
Definition: ImageFile.h:55
float ** GetPixels(void)
Definition: ImageFile.cpp:139
void Allocate(int dataset)
Definition: ImageFile.cpp:50
IMPEX double h[25][1024]
Definition: emor.cpp:169
void SetPixels(float **)
Definition: ImageFile.cpp:130
virtual void Write(char *)=0
unsigned char GetPixel(int x, int y)
Definition: ImageFile.cpp:120
float ** mFloats
Definition: ImageFile.h:83
int *** GetRGBPixels(void)
Definition: ImageFile.h:67
void SetHeight(int h)
Definition: ImageFile.h:59
void SetPixel(int x, int y, unsigned char p)
Definition: ImageFile.h:63