Spinning Topp Logo BlackTopp Studios
inc
graphicsutilities.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _graphicsutilities_cpp
41 #define _graphicsutilities_cpp
42 
43 #include "Graphics/graphicsutilities.h"
44 
45 #include "exception.h"
46 #include "stringtool.h"
47 
48 namespace Mezzanine
49 {
50  namespace Graphics
51  {
53  {
54  StringTools::ToLowerCase(Extension);
55  // Check for the most commonly used formats first.
56  if( Extension == "png" ) return Graphics::IFF_Ext_png;
57  else if( Extension == "bmp" ) return Graphics::IFF_Ext_bmp;
58  else if( Extension == "tga" ) return Graphics::IFF_Ext_tga;
59  else if( Extension == "dds" ) return Graphics::IFF_Ext_dds;
60  else if( Extension == "ktx" ) return Graphics::IFF_Ext_ktx;
61  else if( Extension == "pkm" ) return Graphics::IFF_Ext_pkm;
62  else if( Extension == "pvr" ) return Graphics::IFF_Ext_pvr;
63  // And now the rest
64  else if( Extension == "cut" ) return Graphics::IFF_Ext_cut;
65  else if( Extension == "exr" ) return Graphics::IFF_Ext_exr;
66  else if( Extension == "gif" ) return Graphics::IFF_Ext_gif;
67  else if( Extension == "g3" ) return Graphics::IFF_Ext_g3;
68  else if( Extension == "hdp" ) return Graphics::IFF_Ext_hdp;
69  else if( Extension == "hdr" ) return Graphics::IFF_Ext_hdr;
70  else if( Extension == "ico" ) return Graphics::IFF_Ext_ico;
71  else if( Extension == "iff" ) return Graphics::IFF_Ext_iff;
72  else if( Extension == "jif" ) return Graphics::IFF_Ext_jif;
73  else if( Extension == "jng" ) return Graphics::IFF_Ext_jng;
74  else if( Extension == "jpe" ) return Graphics::IFF_Ext_jpe;
75  else if( Extension == "jpg" ) return Graphics::IFF_Ext_jpg;
76  else if( Extension == "jpeg" ) return Graphics::IFF_Ext_jpeg;
77  else if( Extension == "jp2" ) return Graphics::IFF_Ext_jp2;
78  else if( Extension == "jxr" ) return Graphics::IFF_Ext_jxr;
79  else if( Extension == "j2c" ) return Graphics::IFF_Ext_j2c;
80  else if( Extension == "j2k" ) return Graphics::IFF_Ext_j2k;
81  else if( Extension == "koa" ) return Graphics::IFF_Ext_koa;
82  else if( Extension == "lbm" ) return Graphics::IFF_Ext_lbm;
83  else if( Extension == "mng" ) return Graphics::IFF_Ext_mng;
84  else if( Extension == "pbm" ) return Graphics::IFF_Ext_pbm;
85  else if( Extension == "pcd" ) return Graphics::IFF_Ext_pcd;
86  else if( Extension == "pct" ) return Graphics::IFF_Ext_pct;
87  else if( Extension == "pcx" ) return Graphics::IFF_Ext_pcx;
88  else if( Extension == "pfm" ) return Graphics::IFF_Ext_pfm;
89  else if( Extension == "pgm" ) return Graphics::IFF_Ext_pgm;
90  else if( Extension == "pic" ) return Graphics::IFF_Ext_pic;
91  else if( Extension == "pict" ) return Graphics::IFF_Ext_pict;
92  else if( Extension == "ppm" ) return Graphics::IFF_Ext_ppm;
93  else if( Extension == "psd" ) return Graphics::IFF_Ext_psd;
94  else if( Extension == "ras" ) return Graphics::IFF_Ext_ras;
95  else if( Extension == "sgi" ) return Graphics::IFF_Ext_sgi;
96  else if( Extension == "targa" ) return Graphics::IFF_Ext_targa;
97  else if( Extension == "tif" ) return Graphics::IFF_Ext_tif;
98  else if( Extension == "tiff" ) return Graphics::IFF_Ext_tiff;
99  else if( Extension == "wap" ) return Graphics::IFF_Ext_wap;
100  else if( Extension == "wbm" ) return Graphics::IFF_Ext_wbm;
101  else if( Extension == "wbmp" ) return Graphics::IFF_Ext_wbmp;
102  else if( Extension == "wdp" ) return Graphics::IFF_Ext_wdp;
103  else if( Extension == "webp" ) return Graphics::IFF_Ext_webp;
104  else if( Extension == "xbm" ) return Graphics::IFF_Ext_xbm;
105  else if( Extension == "xpm" ) return Graphics::IFF_Ext_xpm;
106  else{
107  MEZZ_EXCEPTION(ExceptionBase::NOT_IMPLEMENTED_EXCEPTION,"Attempting to convert unsupported image extension as string to ImageFileFormat enum.");
109  }
111  }
112 
114  {
115  switch( Extension )
116  {
117  case Graphics::IFF_Ext_png: return "png";
118  case Graphics::IFF_Ext_bmp: return "bmp";
119  case Graphics::IFF_Ext_tga: return "tga";
120  case Graphics::IFF_Ext_dds: return "dds";
121  case Graphics::IFF_Ext_ktx: return "ktx";
122  case Graphics::IFF_Ext_pkm: return "pkm";
123  case Graphics::IFF_Ext_pvr: return "pvr";
124  case Graphics::IFF_Ext_cut: return "cut";
125  case Graphics::IFF_Ext_exr: return "exr";
126  case Graphics::IFF_Ext_gif: return "gif";
127  case Graphics::IFF_Ext_g3: return "g3";
128  case Graphics::IFF_Ext_hdp: return "hdp";
129  case Graphics::IFF_Ext_hdr: return "hdr";
130  case Graphics::IFF_Ext_ico: return "ico";
131  case Graphics::IFF_Ext_iff: return "iff";
132  case Graphics::IFF_Ext_jif: return "jif";
133  case Graphics::IFF_Ext_jng: return "jng";
134  case Graphics::IFF_Ext_jpe: return "jpe";
135  case Graphics::IFF_Ext_jpg: return "jpg";
136  case Graphics::IFF_Ext_jpeg: return "jpeg";
137  case Graphics::IFF_Ext_jp2: return "jp2";
138  case Graphics::IFF_Ext_jxr: return "jxr";
139  case Graphics::IFF_Ext_j2c: return "j2c";
140  case Graphics::IFF_Ext_j2k: return "j2k";
141  case Graphics::IFF_Ext_koa: return "koa";
142  case Graphics::IFF_Ext_lbm: return "lbm";
143  case Graphics::IFF_Ext_mng: return "mng";
144  case Graphics::IFF_Ext_pbm: return "pbm";
145  case Graphics::IFF_Ext_pcd: return "pcd";
146  case Graphics::IFF_Ext_pct: return "pct";
147  case Graphics::IFF_Ext_pcx: return "pcx";
148  case Graphics::IFF_Ext_pfm: return "pfm";
149  case Graphics::IFF_Ext_pgm: return "pgm";
150  case Graphics::IFF_Ext_pic: return "pic";
151  case Graphics::IFF_Ext_pict: return "pict";
152  case Graphics::IFF_Ext_ppm: return "ppm";
153  case Graphics::IFF_Ext_psd: return "psd";
154  case Graphics::IFF_Ext_ras: return "ras";
155  case Graphics::IFF_Ext_sgi: return "sgi";
156  case Graphics::IFF_Ext_targa: return "targa";
157  case Graphics::IFF_Ext_tif: return "tif";
158  case Graphics::IFF_Ext_tiff: return "tiff";
159  case Graphics::IFF_Ext_wap: return "wap";
160  case Graphics::IFF_Ext_wbm: return "wbm";
161  case Graphics::IFF_Ext_wbmp: return "wbmp";
162  case Graphics::IFF_Ext_wdp: return "wdp";
163  case Graphics::IFF_Ext_webp: return "webp";
164  case Graphics::IFF_Ext_xbm: return "xbm";
165  case Graphics::IFF_Ext_xpm: return "xpm";
167  default:
168  {
169  MEZZ_EXCEPTION(ExceptionBase::NOT_IMPLEMENTED_EXCEPTION,"Attempting to convert unsupported ImageFileFormat enum value to string.");
170  return "";
171  }
172  }
173  return "";
174  }
175  }//Graphics
176 }//Mezzanine
177 
178 #endif
Graphics::ImageFileFormat ConvertImageFileExtension(String Extension)
Converts a String file extension to an ImageFileFormat enum value. an invalid extension string is pro...
Koala Paint image. Gonna level with you, when I looked up this format I found results that references...
(Kodak) Photo CD image. Lossless compression format that supports 24-bits-per-pixel. Does not support Alpha channel.
Truevision Graphics Adapter image. Lossless compression format that supports 24-bit or 32-bit integer...
Icon image. This format isn't an image so much as it is a container for a bmp or png image...
Portable Float Map, an unofficial Netpbm format image. Lossless compression format that supports 8-bi...
PowerVR image. Lossy compression format that supports 2-bit or 4-bit integer pixels formats...
JPEG 2000 image, an alternative name for jp2 image files. See jp2 extension information for more info...
Shorthand for jpeg. See jpeg extension information for more information.
Joint Photographic Experts Group image. Lossy compression format that supports 24-bits-per-pixel inte...
Portable Bitmap, a Netpbm format image. Uncompressed format that supports only 1-bit-per-pixel. Does not support Alpha channel. Writing is supported.
Multiple-image Network Graphics image. This is an animated image format that can have frames encoded ...
Shorthand for tiff. See tiff extension information for more information.
Personal Computer Exchange image. This was the first widely accepted DOS image format! In the off cha...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
Thrown when we just have not coded a thing yet, but we knew what the API should look like...
Definition: exception.h:117
Portable Graymap, a Netpbm format image. Uncompressed format that can support 8-bit or 16-bit pixels ...
Sun Raster image. Lossless compression format that supports 1-bit, 8-bit, and 24-bit integer pixel fo...
(Macintosh QuickDraw) Picture image, an alternative name for pict image files. See pict extension inf...
Silicon Graphics Image. Lossless compression format that supports 24-bit or 48-bit integer pixel form...
JPEG XR image. This extends the the JPEG standard by adding support for lossless compression and enab...
Acronym unknown. Lossless compression format that supports 1-bit-per-pixel integer pixel format...
Alternative name for jxr. See jxr extension information for more information.
Alternative name for jxr. See jxr extension information for more information.
Portable Pixmap, a Netpbm format image. Uncompressed format that can support 8-bit or 16-bit integer ...
This implements the exception hiearchy for Mezzanine.
DirectDraw Surface image. Lossy or Lossless compression format that supports a wide range of pixel fo...
void ToLowerCase(String &Source)
Converts all upper case characters in a string to their respective lower case.
Definition: stringtool.cpp:193
Wireless Bitmap image. Lossless compression format that supports 1-bit-per-pixel integer pixel format...
JPEG 2000 image. This format extends the JPEG format by improving the underlying compression algorith...
Shorthand for wbmp. See wbmp extension information for more information.
Truevision Advanced Raster Graphics Adapter image, an alternative name for tga image files...
X11 Bitmap image. Uncompressed format that uses c-style syntax to provide instructions on how to cons...
Portable Network Graphics image. Lossless compression format that generally is 32-bits-per-pixel inte...
JPEG Network Graphics image. This format extends the JPEG format by supporting Lossless or Lossy comp...
Bitmap image. Lossless compression format that can support most non-float pixel formats. Supports Alpha channel. Writing is supported.
Tagged Image File Format image. Lossless compression format that supports 1-bit, 2-bit, 8-bit, or 32-bit integer pixels formats, as well as 32-bit or 64-bit float or double pixel formats. Supports Alpha channel. Writing is supported.
High Dynamic Ranging image. Lossless compression format that stores RGB in 8-bit colour channels with...
Acronym unknown. Lossless compression format that supports 8-bits-per-pixel integer pixel format if i...
Interchange File Format image. Lossless compression format that supports 8-bit integer colour channel...
Used exclusively in error conditions.
JPEG 2000 Codestream image. This is an image format that is generally embedded inside a jp2 or j2k im...
X11 Pixmap image. Lossless compression format that supports 24-bit integer pixel formats. Does not support Alpha channel. Writing is supported.
JPEG Interchange Format image, subtle alternative in how pixels are packed to the jpeg extension...
Alternative name for ktx. See ktx extension information for more information.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
Photoshop Document image. Normal image format properties are unknown, but psd files are designed to s...
ImageFileFormat
This enum describes the various file formats for images supported by the Mezzanine.
Graphics Interchange Format image. Lossless compression format that supports 8-bits-per-pixel and ani...
(Google) Webp image. Lossless or lossy compression format that supports 8-bit integer colour channels...
(Macintosh QuickDraw) Picture image. This is a file that stores 16-bit opcodes that provide instructi...
Acronym unknown. Uses Ericsson Texture Compression which is lossy and supports 8-bit colour channels...
Interleaved Bitmap image, which is an alternative name to the iff image format. See iff extension inf...
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Acronym unknown. Supports Lossless or Lossy compression with 16-bit float, 32-bit float...
Shorthand for jpeg. See jpeg extension information for more information.
Shorthand for wbmp. See wbmp extension information for more information.
(Macintosh QuickDraw) Picture image, an alternative name for pict image files. See pict extension inf...