00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Lev Povalahev 00017 \author Dan Morris 00018 \version 2.0.0 $Rev: 251 $ 00019 */ 00020 //=========================================================================== 00021 00022 //--------------------------------------------------------------------------- 00023 #ifndef CFileLoaderTGAH 00024 #define CFileLoaderTGAH 00025 //--------------------------------------------------------------------------- 00026 #include <string> 00027 #include <stdio.h> 00028 #include <fstream> 00029 //--------------------------------------------------------------------------- 00030 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00031 00032 typedef unsigned char byte; 00033 typedef unsigned int uint; 00034 enum LImageType {itUndefined, itRGB, itRGBA, itGreyscale}; 00035 00036 #endif // DOXYGEN_SHOULD_SKIP_THIS 00037 //--------------------------------------------------------------------------- 00038 00039 //=========================================================================== 00047 //=========================================================================== 00048 00049 //=========================================================================== 00057 //=========================================================================== 00058 class cFileLoaderTGA 00059 { 00060 public: 00061 00062 //----------------------------------------------------------------------- 00063 // CONSTRUCTOR & DESTRUCTOR: 00064 //----------------------------------------------------------------------- 00065 00067 cFileLoaderTGA(); 00068 00070 cFileLoaderTGA(const std::string &filename); 00071 00073 virtual ~cFileLoaderTGA(); 00074 00075 00076 //----------------------------------------------------------------------- 00077 // METHODS: 00078 //----------------------------------------------------------------------- 00079 00081 bool LoadFromFile(const std::string &filename); 00082 00083 00084 //----------------------------------------------------------------------- 00085 // MEMBERS: 00086 //----------------------------------------------------------------------- 00087 00092 uint GetAlphaDepth(); 00093 00095 uint GetImageWidth(); 00096 00098 uint GetImageHeight(); 00099 00104 uint GetPixelDepth(); 00105 00110 byte* GetPixels(); 00111 00118 LImageType GetImageType(); 00119 00121 byte *m_pixels; 00122 00123 protected: 00124 00125 00126 //----------------------------------------------------------------------- 00127 // METHODS: 00128 //----------------------------------------------------------------------- 00129 00131 void Clear(); 00132 00133 00134 //----------------------------------------------------------------------- 00135 // MEMBERS: 00136 //----------------------------------------------------------------------- 00137 00139 uint m_pixelDepth; 00140 00142 uint m_alphaDepth; 00143 00145 uint m_height; 00146 00148 uint m_width; 00149 00151 LImageType m_type; 00152 00154 bool m_loaded; 00155 }; 00156 00157 //--------------------------------------------------------------------------- 00158 #endif 00159 //---------------------------------------------------------------------------