33 #ifndef __INCLUDE_MIST_IMAGE__
34 #define __INCLUDE_MIST_IMAGE__
37 #ifndef __INCLUDE_MIST_H__
41 #ifndef __INCLUDE_MIST_BMP__
45 #ifndef __INCLUDE_MIST_PNG__
49 #ifndef __INCLUDE_MIST_GIF__
53 #ifndef __INCLUDE_MIST_TIFF__
57 #ifndef __INCLUDE_MIST_JPEG__
61 #ifndef __INCLUDE_MIST_PNM__
65 #ifndef __INCLUDE_MIST_TGA__
77 namespace __image_controller__
79 inline std::string to_lower_case(
const std::string &str )
82 for( std::string::size_type i = 0 ; i < str.size( ) ; i++ )
84 s +=
static_cast< char >( tolower( str[ i ] ) );
89 inline std::string get_ext(
const std::string &str )
91 std::string::size_type index = str.rfind(
'.' );
92 if( index == str.npos )
96 return( str.substr( index ) );
121 template <
class T,
class Allocator >
126 std::string ext = __image_controller__::to_lower_case( __image_controller__::get_ext( filename ) );
133 if( ext ==
".jpeg" || ext ==
".jpg" )
137 else if( ext ==
".bmp" )
141 else if( ext ==
".tiff" || ext ==
".tif" )
145 else if( ext ==
".png" )
149 else if( ext ==
".pbm" || ext ==
".pgm" || ext ==
".ppm" || ext ==
".pnm" )
153 else if( ext ==
".tga" )
157 else if( ext ==
".gif" )
178 template <
class T,
class Allocator >
195 template <
class T,
class Allocator >
200 std::string ext = __image_controller__::to_lower_case( __image_controller__::get_ext( filename ) );
203 std::cerr <<
"Unknown file type!" << std::endl;
207 if( image.
width( ) == 0 )
209 std::cerr <<
"Image width is zero!" << std::endl;
212 else if( image.
height( ) == 0 )
214 std::cerr <<
"Image height is zero!" << std::endl;
219 if( ext ==
".jpeg" || ext ==
".jpg" )
223 else if( ext ==
".bmp" )
227 else if( ext ==
".tiff" || ext ==
".tif" )
231 else if( ext ==
".png" )
235 else if( ext ==
".pbm" )
239 else if( ext ==
".pgm" )
243 else if( ext ==
".ppm" || ext ==
".pnm" )
247 else if( ext ==
".tga" )
269 template <
class T,
class Allocator >
283 #endif // __INCLUDE_MIST_IMAGE__