Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

ExCImageLoader.h

Aller à la documentation de ce fichier.
00001 /************************************************************************/
00002 /* Ex Nihlo Engine by Hermanns Christophe                                                               */
00003 /************************************************************************/
00004 /* This program is free software; you can redistribute it and/or                */
00005 /* modify it under the terms of the GNU General Public License                  */
00006 /* as published by the Free Software Foundation; either version 2               */
00007 /* of the License, or (at your option) any later version.                               */
00008 /*                                                                                                                                              */
00009 /* This program is distributed in the hope that it will be useful,              */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of               */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
00012 /*                                                                                                                                              */
00013 /* See the GNU General Public License for more details.                                 */
00014 /*                                                                                                                                              */
00015 /* You should have received a copy of the GNU General Public License    */
00016 /* along with this program; if not, write to the Free Software                  */
00017 /* Foundation, Inc., 59 Temple Place - Suite 330,                                               */
00018 /* Boston, MA  02111-1307, USA.                                                                                 */
00019 /*                                                                                                                                              */
00020 /* If you use a important part of this code please send me a mail               */
00021 /* I just want to see where my code go thks :)                                                  */
00022 /************************************************************************/
00023 
00024 /************************************************************************/
00025 /* Contact                                                              */  
00026 /************************************************************************/
00027 /* ExNihilo Website :www.ploksoftware.org                               */
00028 /*                                                                      */
00029 /* Hermanns Christophe ExNihilo creator and main programmer             */
00030 /*                                                                      */
00031 /* Mail             : Data@ploksoftware.org                                                             */
00032 /* ICQ              : 8030901                                                                                   */
00033 /* MSN Messenger    : Data_7@hotmail.com                                                                */
00034 /*                                                                      */
00035 /* Benjamin Michotte Linux port, webmaster                              */
00036 /*                                                                      */
00037 /* Mail             :binny@ploksoftware.org                             */
00038 /*                                                                      */
00039 /************************************************************************/
00040 
00041 /************************************************************************/
00042 /* File Description                                                                                             */
00043 /************************************************************************/
00044 /* File Name   :ExCImageLoader.h                                                                                */
00045 /*                                                                                                                                              */
00046 /* Start Date   :03/15/2002                                                                                             */
00047 /*                                                                                                                                              */
00048 /* Last Update :06/20/2003                                              */
00049 /*                                                                                                                                              */
00050 /* File Description :                                                                                                   */
00051 /*                                                                      */
00052 /* For update of this file check : www.ploksoftware.org                 */
00053 /************************************************************************/ 
00054 
00055 #ifndef __EXCIMAGELOADER__
00056 #define __EXCIMAGELOADER__
00057 //--------------------------------
00058 // File to include
00059 //--------------------------------
00060 #include "ExDefine.h"
00061 #include "Math/ExMath.h"
00062 #include "ExNihiloExecption.h"
00063 #include "ExNihiloNameSpace.h"
00064 //--------------------------------
00065 #include <ddraw.h>
00066 //--------------------------------
00067 // Define type
00068 //--------------------------------
00069 #define TGA_RGB          2              // Normal RGB file
00070 #define TGA_A            3              // ALPHA file
00071 #define TGA_RLE         10              // Run-Length Encoded (RLE) file
00072 //-------------------------------
00073 enum TextureType
00074 {
00075         BMP,TGA,PCX,JPG,RGB,RAW,PPM,DDS,UNKNOWN
00076 };
00077 
00078 //-------------------------------
00079 class ExCImageLoader
00080 {
00081 private:
00082         //--------------------------------
00083         // Header 
00084         //--------------------------------
00085         typedef struct
00086         {
00087                 unsigned char manufacturer;
00088                 unsigned char version;
00089                 unsigned char encoding;
00090                 unsigned char bits;
00091                 unsigned char xMin;
00092                 unsigned char yMin;
00093                 unsigned char xMax;
00094                 unsigned char yMax;
00095                 unsigned char *palette;
00096         } PCXHEADER;
00097 
00098         typedef struct tagBITMAPINFOHEADER{
00099                 DWORD      biSize;
00100                 LONG       biWidth;
00101                 LONG       biHeight;
00102                 WORD       biPlanes;
00103                 WORD       biBitCount;
00104                 DWORD      biCompression;
00105                 DWORD      biSizeImage;
00106                 LONG       biXPelsPerMeter;
00107                 LONG       biYPelsPerMeter;
00108                 DWORD      biClrUsed;
00109                 DWORD      biClrImportant;
00110         } BITMAPINFOHEADER;
00111 
00112 
00113 //--------------------------------
00114 // Methode
00115 //--------------------------------
00116         unsigned char *LoadPCXFile(std::string filename, PCXHEADER *pcxHeader);
00117         //void DecodeJPG(jpeg_decompress_struct* cinfo, tImage *pImageData);
00118         TextureType FindTextureType(std::string FileName);
00119 public:
00120 //--------------------------------
00121 // Variable
00122 //--------------------------------
00123         TextureType             m_TextureType;
00124         int                             m_channels;                     // The channels in the image (3 = RGB : 4 = RGBA)
00125         int                             m_sizeX;                                // The width of the image in pixels
00126         int                             m_sizeY;                                // The height of the image in pixels
00127         long int                m_scaledWidth;
00128         long int                m_scaledHeight;
00129         unsigned int    m_type;         // RGB,RGBA...
00130         unsigned char   *m_data;        // The image pixel data
00131         unsigned char   *m_palette;
00132         
00133 
00134         int                             m_ddsBufsize;
00135         int                             m_ddsNumMipmaps;
00136         int                             m_ddsFormat;
00137         int                             m_ddsComponent;
00138 //--------------------------------
00139 // Constructor // Destructor
00140 //--------------------------------
00141         ExCImageLoader(void);
00142         ExCImageLoader(std::string FileName);
00143         ~ExCImageLoader(void);
00144 //--------------------------------
00145 // Methode
00146 //--------------------------------
00147         bool LoadImage(std::string FileName);
00148         //bool LoadImage(const char *strFileName);
00149         bool LoadBMP(const char *strFileName);
00150 
00151         bool LoadBMP(std::string strFileName);
00152         bool LoadTGA(std::string strFileName);
00153         bool LoadJPG(std::string strFileName);
00154         bool LoadPCX(std::string strFileName);
00155         bool LoadRAW(std::string strFileName);
00156         bool LoadRGB(std::string strFileName);
00157         bool LoadPPM(std::string strFileName);
00158         bool LoadDDS(std::string strFileName);
00159 
00160         bool SaveImage(std::string FileName,int width,int height);
00161 
00162         bool SaveBMP(std::string strFileName,int width,int height,unsigned char * ImageData);
00163         bool SaveTGA(std::string strFileName,int width,int height,unsigned char * ImageData);
00164         bool SaveJPG(std::string strFileName,int width,int height,unsigned char * ImageData);
00165         bool SavePCX(std::string strFileName,int width,int height,unsigned char * ImageData);
00166         bool SaveRAW(std::string strFileName,int width,int height,unsigned char * ImageData);
00167         bool SaveRGB(std::string strFileName,int width,int height,unsigned char * ImageData);
00168         bool SavePPM(std::string strFileName,int width,int height,unsigned char * ImageData);
00169 };
00170 
00171 #endif //__EXCIMAGELOADER__
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 

Généré le Tue Oct 28 12:43:30 2003 pour ExNihilo par doxygen 1.3.4