00001
00002
00003
00004 #ifndef COURNIA_IMAGE_H
00005 #define COURNIA_IMAGE_H 1
00006
00007 #include "rect.h"
00008
00010
00013 namespace image
00014 {
00015 class image_t;
00016 }
00017
00019
00022 class image::image_t
00023 {
00024 public:
00026 enum format
00027 {
00028 GREYSCALE = 1,
00029 RGB = 3,
00030 RGBA = 4
00031 };
00032
00034 enum bpc
00035 {
00036 BYTE = 8,
00037 WORD = 32,
00038 DWORD = 64
00039 };
00040
00041 private:
00042 unsigned int m_width;
00043 unsigned int m_height;
00044 format m_format;
00045 unsigned int m_depth;
00046 unsigned int m_pixel_size;
00047 unsigned int m_row_size;
00048 unsigned int m_image_size;
00049 unsigned int m_seek_pos;
00050 unsigned char *m_seek_ptr;
00051 unsigned char *m_pixels;
00052
00053
00054 image_t( const image_t& img );
00055 image_t& operator=( const image_t& img );
00056
00057 public:
00059
00065 image_t( unsigned int width, unsigned int height, format fmat,
00066 unsigned int depth );
00067
00069
00076 image_t( unsigned int width, unsigned int height, format fmat,
00077 unsigned int depth, const void *pixels );
00078
00079
00080 ~image_t( void );
00081
00083 inline unsigned int get_width( void ) const {
00084 return m_width;
00085 }
00086
00088 inline unsigned int get_height( void ) const {
00089 return m_height;
00090 }
00091
00093 inline format get_format( void ) const {
00094 return m_format;
00095 }
00096
00098 inline unsigned int get_bpc( void ) const {
00099 return m_depth;
00100 }
00101
00103 inline const void* get_pixels( void ) const {
00104 return m_pixels;
00105 }
00106
00108
00111 bool seek( unsigned int x, unsigned int y );
00112
00114
00120 bool read( unsigned char &gray );
00121
00123
00131 bool read( unsigned char &r, unsigned char &g, unsigned char &b );
00132
00134
00143 bool read( unsigned char &r, unsigned char &g, unsigned char &b,
00144 unsigned char &a );
00145
00147
00153 bool write( unsigned char gray );
00154
00156
00164 bool write( unsigned char r, unsigned char g, unsigned char b );
00165
00167
00176 bool write( unsigned char r, unsigned char g, unsigned char b,
00177 unsigned char a );
00178
00180
00189 bool get_pixel( unsigned char &r, unsigned char &g, unsigned char &b,
00190 unsigned int x, unsigned int y ) const;
00191
00192
00194
00203 bool get_pixel( unsigned char &r, unsigned char &g, unsigned char &b,
00204 unsigned char &a, unsigned int x, unsigned int y ) const;
00205
00206
00207
00209
00218 bool set_pixel( unsigned char r, unsigned char g, unsigned char b,
00219 unsigned int x, unsigned int y );
00220
00222
00231 bool set_pixel( unsigned char r, unsigned char g, unsigned char b,
00232 unsigned char a, unsigned int x, unsigned int y );
00233
00234
00235
00237 bool blend_pixel( unsigned char r, unsigned char g, unsigned char b,
00238 unsigned char a, unsigned int x, unsigned int y );
00239
00241 void flip_horizontal( void );
00242
00244
00249 bool blit( const image_t& img, const recti& region );
00250
00252
00257 bool blend( const image_t& img, const recti& region );
00258 };
00259
00260 #endif