00001
00002
00003 #ifndef IMAGE_H
00004 #define IMAGE_H
00005
00006
00007 #include "Configuration.h"
00008 #include "Renderer.h"
00009
00010 #include <string>
00011
00012
00013 namespace pge {
00014
00015
00016 class Image {
00017 public:
00018
00019
00020
00021
00022
00023 enum ImageType {
00024 RGB,
00025 RGBA,
00026 Unknown
00027 };
00028
00029
00030
00031
00032
00033
00034
00036 Image(const std::string &fileName, bool alpha = false, int ar = ALPHA_COLOR_R,
00037 int ag = ALPHA_COLOR_G, int ab = ALPHA_COLOR_B);
00038
00040 Image(unsigned char *image, int width, int height, int bits, ImageType type,
00041 bool alpha = false, int ar = ALPHA_COLOR_R, int ag = ALPHA_COLOR_G,
00042 int ab = ALPHA_COLOR_B);
00043
00044
00045
00046
00047
00048
00049
00051 ~Image(void);
00052
00053
00054
00055
00056
00057
00058
00060 bool isLoaded(void) {
00061 return m_loadOk;
00062 }
00063
00065 const std::string& getFileName(void) const {
00066 return m_fileName;
00067 }
00068
00070 ImageType getType(void) {
00071 return m_type;
00072 }
00073
00075 unsigned char* getImage(void) {
00076 return m_image;
00077 }
00078
00080 int getWidth(void) {
00081 return m_width;
00082 }
00083
00085 int getHeight(void) {
00086 return m_height;
00087 }
00088
00090 int getBitsPerPixel(void) {
00091 return m_bitsPerPixel;
00092 }
00093
00095 void swapBGRToRGB(void);
00096
00098 void addAlphaChannel(int ar, int ag, int ab);
00099
00100
00101 private:
00102
00103
00104
00105
00106
00108 bool loadFile(int alpha, bool swapBGR, int ar, int ag, int ab);
00109
00111 bool loadTargaFile(int alpha, int ar, int ag, int ab);
00112
00113
00114
00115
00116
00117
00118
00120 std::string m_fileName;
00121
00123 ImageType m_type;
00124
00126 unsigned char *m_image;
00127
00129 int m_width;
00130
00132 int m_height;
00133
00135 int m_bitsPerPixel;
00136
00138 bool m_loadOk;
00139 };
00140 };
00141
00142 #endif