Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglImageLoader.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglImageLoader.hpp
00021  *   Author: Scott McMillan
00022  *  Created: 15 February 2001
00023  *  Summary: Abstract base class for all 3D model loaders.
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:  // Variables
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

Generated at Mon Jul 1 18:00:04 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001