/src/ogre/PlugIns/STBICodec/include/OgreSTBICodec.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef __STBICodec_H__ |
29 | | #define __STBICodec_H__ |
30 | | |
31 | | #include "OgreSTBICodecExports.h" |
32 | | #include "OgreImageCodec.h" |
33 | | #include "OgrePlugin.h" |
34 | | |
35 | | namespace Ogre { |
36 | | |
37 | | /** \addtogroup Plugins Plugins |
38 | | * @{ |
39 | | */ |
40 | | /** \defgroup STBIImageCodec STBIImageCodec |
41 | | * %Codec for loading generic image formats (e.g. jpg, png) using [stb_image](https://github.com/nothings/stb) |
42 | | * |
43 | | * This Codec is ideal for files, that you are in control of. There are no external dependencies and no superfluous pixel conversions. |
44 | | * The downside is that not all format variants are supported and the code is more vulnerable to malicious files. |
45 | | * @{ |
46 | | */ |
47 | | class STBIImageCodec : public ImageCodec |
48 | | { |
49 | | private: |
50 | | String mType; |
51 | | |
52 | | typedef std::list<ImageCodec*> RegisteredCodecList; |
53 | | static RegisteredCodecList msCodecList; |
54 | | |
55 | | public: |
56 | | STBIImageCodec(const String &type); |
57 | 56.9k | virtual ~STBIImageCodec() { } |
58 | | |
59 | | DataStreamPtr encode(const Any& input) const override; |
60 | | void encodeToFile(const Any& input, const String& outFileName) const override; |
61 | | void decode(const DataStreamPtr& input, const Any& output) const override; |
62 | | |
63 | | String getType() const override; |
64 | | String magicNumberToFileExt(const char *magicNumberPtr, size_t maxbytes) const override; |
65 | | |
66 | | /// Static method to startup and register the codecs |
67 | | _OgreSTBICodecExport static void startup(void); |
68 | | /// Static method to shutdown and unregister the codecs |
69 | | _OgreSTBICodecExport static void shutdown(void); |
70 | | }; |
71 | | /** @} */ |
72 | | /** @} */ |
73 | | |
74 | | } // namespace |
75 | | |
76 | | #endif |