Basic Image AlgorithmS Library 2.8.0

glfFormatDB.hh

00001 /*
00002  This file is part of the BIAS library (Basic ImageAlgorithmS).
00003 
00004  Copyright (C) 2003-2009    (see file CONTACT for details)
00005  Multimediale Systeme der Informationsverarbeitung
00006  Institut fuer Informatik
00007  Christian-Albrechts-Universitaet Kiel
00008 
00009 
00010  BIAS is free software; you can redistribute it and/or modify
00011  it under the terms of the GNU Lesser General Public License as published by
00012  the Free Software Foundation; either version 2.1 of the License, or
00013  (at your option) any later version.
00014 
00015  BIAS is distributed in the hope that it will be useful,
00016  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  GNU Lesser General Public License for more details.
00019 
00020  You should have received a copy of the GNU Lesser General Public License
00021  along with BIAS; if not, write to the Free Software
00022  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 
00025 #ifndef __glfFormatDB_hh__
00026 #define __glfFormatDB_hh__
00027 
00028 #include "glfCommon.hh"
00029 #include <Base/Image/ImageBase.hh>
00030 
00031 
00032 namespace BIAS {
00033 
00034   /** \brief Helper methods for format conversions in GL and between GL and BIAS.
00035    * Class originates from glfTexture methods which from now on are deprecated and will be removed.
00036    * \ingroup g_openglframework
00037    * \author bartczak 12/2009
00038    **/
00039   class BIASOpenGLFramework_EXPORT glfFormatDB {
00040   public:
00041     /**
00042      * Computes a pixel format that can be used with <code>glGetTexImage</code>
00043      * and <code>glReadPixels</code>
00044      * for an internal format of a texture. Also returns the number of channels.
00045      * For example: If internalFormat = GL_R3_G3_B2, then format = GL_RGB
00046      * and numChannels = 3.
00047      */
00048     static void GetFormatForInternalFormat(GLenum internalFormat,
00049                                            GLenum& format,
00050                                            int& numChannels);
00051     
00052     /**
00053      * Returns the OpenGL pixel type (GL_UNSIGNED_BYTE etc.) for a BIAS storage type.
00054      */
00055     static GLenum GetPixelTypeForStorageType(ImageBase::EStorageType storageType);
00056 
00057     /**
00058      * Returns the OpenGL pixel format (GL_RGB etc.) for a BIAS color model.
00059      */
00060     static GLenum GetFormatForColorModel(ImageBase::EColorModel colorModel);
00061 
00062     /**
00063      * Returns an OpenGL internal pixel format for a BIAS storage type and color model.
00064      */
00065     static GLenum ProposeInternalFormat(ImageBase::EStorageType storageType,
00066                                         ImageBase::EColorModel colorModel);
00067 
00068     /** Taking the enum as string and converting to the appropriate numerical constant.
00069      **/
00070     static GLenum GLenumFromString(const std::string& enumString);
00071 
00072     /** Returns the number of channels required to store an image of
00073       * specified texture format, e.g. GL_RED returns 1 while GL_RGBA returns 4.
00074       */
00075     static int ChannelsFromGLFormat(GLenum textureFormat);
00076     
00077   };
00078 
00079 }
00080 
00081 #endif
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends