00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029
00031 #ifndef __FREEIMAGELOADER_H__
00032 #define __FREEIMAGELOADER_H__
00033
00034 #include "H3DImageLoaderNode.h"
00035
00036 #ifdef HAVE_FREEIMAGE
00037
00038 #include "FreeImageImage.h"
00039
00040 namespace H3D {
00047 class H3DAPI_API FreeImageLoader : public H3DImageLoaderNode {
00048 public:
00050 FreeImageLoader() {
00051 type_name = "FreeImageLoader";
00052 }
00053
00056 virtual Image *loadImage( const string &url ) {
00057
00058 FREE_IMAGE_FORMAT format = FreeImage_GetFileType( url.c_str() );
00059 if( format == FIF_UNKNOWN ) {
00060 format = FreeImage_GetFIFFromFilename( url.c_str() );
00061 }
00062
00063 if( format != FIF_UNKNOWN && FreeImage_FIFSupportsReading( format ) ) {
00064 FIBITMAP *bm = FreeImage_Load( format, url.c_str() );
00065
00066 if( bm ) {
00067
00068
00069 if( FreeImage_GetColorType( bm ) == FIC_RGB && FreeImage_GetBPP( bm ) == 32 ) {
00070 FIBITMAP *old = bm;
00071 bm = FreeImage_ConvertTo24Bits( bm );
00072 FreeImage_Unload( old );
00073 }
00074 return new FreeImageImage( bm );
00075 }
00076 }
00077 return NULL;
00078 }
00079
00082
00085 static bool supportsFileType( const string &url );
00086
00087 static H3DNodeDatabase database;
00088
00090 static FileReaderRegistration reader_registration;
00091 };
00092 }
00093
00094 #endif // HAVE_FREEIMAGE
00095 #endif