Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
glfFormatDB.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __glfFormatDB_hh__
26 #define __glfFormatDB_hh__
27 
28 #include "glfCommon.hh"
29 #include <Base/Image/ImageBase.hh>
30 
31 
32 namespace BIAS {
33 
34  /** \brief Helper methods for format conversions in GL and between GL and BIAS.
35  * Class originates from glfTexture methods which from now on are deprecated and will be removed.
36  * \ingroup g_openglframework
37  * \author bartczak 12/2009
38  **/
39  class BIASOpenGLFramework_EXPORT glfFormatDB {
40  public:
41  /**
42  * Computes a pixel format that can be used with <code>glGetTexImage</code>
43  * and <code>glReadPixels</code>
44  * for an internal format of a texture. Also returns the number of channels.
45  * For example: If internalFormat = GL_R3_G3_B2, then format = GL_RGB
46  * and numChannels = 3.
47  */
48  static void GetFormatForInternalFormat(GLenum internalFormat,
49  GLenum& format,
50  int& numChannels);
51 
52  /**
53  * Returns the OpenGL pixel type (GL_UNSIGNED_BYTE etc.) for a BIAS storage type.
54  */
55  static GLenum GetPixelTypeForStorageType(ImageBase::EStorageType storageType);
56 
57  /**
58  * Returns the OpenGL pixel format (GL_RGB etc.) for a BIAS color model.
59  */
60  static GLenum GetFormatForColorModel(ImageBase::EColorModel colorModel);
61 
62  /**
63  * Returns an OpenGL internal pixel format for a BIAS storage type and color model.
64  */
65  static GLenum ProposeInternalFormat(ImageBase::EStorageType storageType,
66  ImageBase::EColorModel colorModel);
67 
68  /** Taking the enum as string and converting to the appropriate numerical constant.
69  **/
70  static GLenum GLenumFromString(const std::string& enumString);
71 
72  /** Returns the number of channels required to store an image of
73  * specified texture format, e.g. GL_RED returns 1 while GL_RGBA returns 4.
74  */
75  static int ChannelsFromGLFormat(GLenum textureFormat);
76 
77  };
78 
79 }
80 
81 #endif
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
Helper methods for format conversions in GL and between GL and BIAS.
Definition: glfFormatDB.hh:39