00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SGL_IMAGE_LOADER
00027 #define SGL_IMAGE_LOADER
00028
00029 #include <sgldb.h>
00030 #include <sglDataLoader.hpp>
00031 #include <sglTexture.hpp>
00032 #include <map>
00033
00034
00038 class SGLDB_DLL_API sglImageLoader : public sglDataLoader
00039 {
00040 public:
00042 typedef void *(*loaderFunc)(const string &filepath,
00043 unsigned int &width,
00044 unsigned int &height,
00045 sglTexture::ExternalFormatEnum &format,
00046 sglTexture::TypeEnum &type);
00047
00049 typedef bool (*writerFunc)(const string &filepath,
00050 const void *image,
00051 unsigned int width,
00052 unsigned int height,
00053 sglTexture::ExternalFormatEnum format,
00054 sglTexture::TypeEnum type);
00055
00056 public:
00058 virtual ~sglImageLoader() = 0;
00059
00070 static void* loadImage(const string &filepath,
00071 unsigned int &width,
00072 unsigned int &height,
00073 sglTexture::ExternalFormatEnum &format,
00074 sglTexture::TypeEnum &type);
00075
00086 static bool writeImage(const string &filepath,
00087 const void *image,
00088 unsigned int width,
00089 unsigned int height,
00090 sglTexture::ExternalFormatEnum format,
00091 sglTexture::TypeEnum type);
00092
00099 static void registerImageLoader(const string &extension,
00100 loaderFunc image_loader_func);
00101
00108 static void registerImageWriter(const string &extension,
00109 writerFunc image_writer_func);
00110
00115 static loaderFunc getImageLoader(const string &extension);
00116
00121 static writerFunc getImageWriter(const string &extension);
00122
00133 static void *reformatImage(
00134 sglTexture::ExternalFormatEnum old_format,
00135 sglTexture::TypeEnum type,
00136 unsigned int num_s, unsigned int num_t,
00137 sglTexture::ExternalFormatEnum new_format,
00138 const void *old_image);
00139
00150 static void scaleImageComponent(
00151 void* image, sglTexture::ExternalFormatEnum format,
00152 sglTexture::TypeEnum type,
00153 unsigned int num_s, unsigned int num_t,
00154 float scale, unsigned int component);
00155
00166 static void *changeImageType(
00167 sglTexture::ExternalFormatEnum format,
00168 sglTexture::TypeEnum old_type,
00169 unsigned int num_s, unsigned int num_t,
00170 sglTexture::TypeEnum new_type,
00171 const void *old_image);
00172
00173 protected:
00174 sglImageLoader();
00175 sglImageLoader(const sglImageLoader &);
00176 sglImageLoader &operator=(const sglImageLoader &);
00177
00178 private:
00179 static map<string, loaderFunc> s_extension_loader_map;
00180 static map<string, writerFunc> s_extension_writer_map;
00181 static sglLock s_lock;
00182 };
00183
00184 #endif