KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
jpeg.h
Go to the documentation of this file.
1 // jpeg.h - wrapper class for reading a jpeg image
3 // Author: Doron Tal
4 // Date created: March, 2000
5 
6 #ifndef _JPEG_H
7 #define _JPEG_H
8 
10 //Added by Prasad
11 //To allow for float precision for image pixels
12 //NOTE***********Make sure the following is undefined when using any
13 //of the following functions:
14 //BGR2Gray, BGR2L, BGR2L
15 //because they assume char precision for image pixels***************
16 
17 #define ENABLE_FLOAT_PRECISION
18 
20 #include <stdlib.h>
21 #include <string.h>
22 #include <math.h>
23 #include <i/i_float.h>
24 
25 
26 namespace DTLib {
27 
28  class CJPEG {
29 
30  public:
31  CJPEG();
32  ~CJPEG();
33 
34  // reads a Jpeg Image from file designated by 'filename'
35  bool ReadImg(const char* filename);
36 
37  // returns Width/Height of image read by ReadImg()
38  int Width() { return m_Width; }
39  int Height() { return m_Height; }
40 
41  // returns number of bytes per pixel read by prev. call to ReadImg()
42  int nBytesPerPixel() { return m_BytesPerPixel; }
43 
44  bool Convert_from_kjb(const kjb_c::KJB_image * ip);
45 
46 
48 //Added by Prasad
49 //To allow for float precision for image pixels
50 
51 #ifdef ENABLE_FLOAT_PRECISION
52  // returns the buffer read by prev. call to ReadImg()
53  float* pBuffer() { return m_pBuffer; }
54 #else
55  // returns the buffer read by prev. call to ReadImg()
56  unsigned char* pBuffer() { return m_pBuffer; }
57 #endif
58 
60  // if you call this function with 'bDelete' == false,
61  // the destructor of this class will not free m_pBuffer, otherwise
62  // the default behavior is to free m_pBuffer.
63  void Deallocate(bool bDelete) { m_bDelete = bDelete; }
64 
65  private:
66 
67  int m_Width;
68  int m_Height;
69  int m_BytesPerPixel;
71 //Added by Prasad
72 //To allow for float precision for image pixels
73 
74 #ifdef ENABLE_FLOAT_PRECISION
75  float* m_pBuffer;
76 #else
77  unsigned char* m_pBuffer;
78 #endif
79 
81  bool m_bDelete;
82  };
83 
84 } // namespace DTLib {
85 
86 #endif /*#ifndef _JPEG_H */
Definition: jpeg.h:28
int Height()
Definition: jpeg.h:39
~CJPEG()
Definition: jpeg.cpp:48
int Width()
Definition: jpeg.h:38
CJPEG()
Definition: jpeg.cpp:40
float * pBuffer()
Definition: jpeg.h:53
int nBytesPerPixel()
Definition: jpeg.h:42
void Deallocate(bool bDelete)
Definition: jpeg.h:63
bool ReadImg(const char *filename)
Definition: jpeg.cpp:75
bool Convert_from_kjb(const kjb_c::KJB_image *ip)
Definition: jpeg.cpp:55