gbLib/include/gbImageLoader.hpp

Go to the documentation of this file.
00001 
00013 #ifndef _GHULBUSUTIL_IMAGELOADER_HPP_INCLUDE_GUARD_
00014 #define _GHULBUSUTIL_IMAGELOADER_HPP_INCLUDE_GUARD_
00015 
00016 #include <fstream>
00017 
00018 #include "gbException.hpp"
00019 #include "gbColor.hpp"
00020 
00023 namespace GhulbusUtil {
00026     class gbImageLoader {
00027     public:
00030         class gbImageType {
00031         public:
00041             virtual void ReadFile(std::ifstream& file, int* width, int* height, int* bpp, 
00042                                 unsigned char** pp_data, unsigned int** pp_palette)=0;
00047             virtual bool CheckFile(std::ifstream const& file)=0;
00050             virtual ~gbImageType();
00051         };
00052     private:
00053         unsigned char* m_data;          
00054         unsigned int* m_palette;        
00055         int m_width;                    
00056         int m_height;                   
00057         int m_bpp;                      
00058     public:
00066         gbImageLoader(char const* fname, gbImageType* img_type);
00069         ~gbImageLoader();
00073         int GetWidth() const;
00077         int GetHeight() const;
00081         int GetBpp() const;
00085         bool HasPalette() const;
00089         void GetImageData(unsigned char* pData) const;
00094         void GetImageData32(GhulbusGraphics::GBCOLOR* pData) const;
00099         void GetPaletteData(GhulbusGraphics::GBCOLOR* pPal) const;
00102         void FlipV();
00103     };
00104 
00112     void WriteImage(char const* fname, GhulbusGraphics::GBCOLOR const* data, int width, int height);
00113 
00117     gbImageLoader::gbImageType* gbImageType_BMP();
00118     class gbImageType_BMP_T: public gbImageLoader::gbImageType {
00119     private:
00120         unsigned int m_file_offset;         
00121     public:
00122         void ReadFile(std::ifstream& file, int* width, int* height, int* bpp, 
00123             unsigned char** pp_data, unsigned int** pp_palette);
00124         bool CheckFile(std::ifstream const& file);
00125         gbImageType_BMP_T();
00126         virtual ~gbImageType_BMP_T();
00127     };
00128 
00132     gbImageLoader::gbImageType* gbImageType_TGA();
00133     class gbImageType_TGA_T: public gbImageLoader::gbImageType {
00134     private:
00135         unsigned int m_file_offset;         
00136     public:
00137         void ReadFile(std::ifstream& file, int* width, int* height, int* bpp, 
00138             unsigned char** pp_data, unsigned int** pp_palette);
00139         bool CheckFile(std::ifstream const& file);
00140         gbImageType_TGA_T();
00141         virtual ~gbImageType_TGA_T();
00142     };
00143 };
00144 
00145 #endif

Generated on Sat Jan 19 18:58:21 2008 for PS2 IconSys Library by  doxygen 1.5.4