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-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef _Ogre_ILUtil_H__ |
---|
30 | #define _Ogre_ILUtil_H__ |
---|
31 | |
---|
32 | #include <OgrePrerequisites.h> |
---|
33 | #include <OgreCommon.h> |
---|
34 | #include <OgrePixelFormat.h> |
---|
35 | |
---|
36 | namespace Ogre { |
---|
37 | |
---|
38 | /* |
---|
39 | * DevIL specific utility class |
---|
40 | **/ |
---|
41 | class _OgrePrivate ILUtil { |
---|
42 | public: |
---|
43 | /// Structure that encapsulates a devIL image format definition |
---|
44 | struct ILFormat { |
---|
45 | /// Construct an invalidated ILFormat structure |
---|
46 | ILFormat(): |
---|
47 | numberOfChannels(0), format(-1), type(-1) {}; |
---|
48 | |
---|
49 | /// Construct a ILFormat from parameters |
---|
50 | ILFormat(int channels, int format, int type=-1): |
---|
51 | numberOfChannels(channels), format(format), type(type) {} |
---|
52 | |
---|
53 | /// Return wether this structure represents a valid DevIL format |
---|
54 | bool isValid() { return format!=-1; } |
---|
55 | |
---|
56 | /// Number of channels, usually 3 or 4 |
---|
57 | int numberOfChannels; |
---|
58 | /// IL_RGBA,IL_BGRA,IL_DXTx, ... |
---|
59 | int format; |
---|
60 | /// IL_UNSIGNED_BYTE, IL_UNSIGNED_SHORT, ... may be -1 for compressed formats |
---|
61 | int type; |
---|
62 | }; |
---|
63 | |
---|
64 | /** Get OGRE format to which a given IL format can be most optimally converted. |
---|
65 | */ |
---|
66 | static PixelFormat ilFormat2OgreFormat( int ImageFormat, int ImageType ); |
---|
67 | /** Get IL format that matches a given OGRE format exactly in memory. |
---|
68 | @remarks Returns an invalid ILFormat (.isValid()==false) when |
---|
69 | there is no IL format that matches this. |
---|
70 | */ |
---|
71 | static ILFormat OgreFormat2ilFormat( PixelFormat format ); |
---|
72 | /** Convert current IL image to an OGRE format. The size of the target will be |
---|
73 | PixelUtil::getNumElemBytes(fmt) * ilGetInteger( IL_IMAGE_WIDTH ) * ilGetInteger( IL_IMAGE_HEIGHT ) * ilGetInteger( IL_IMAGE_DEPTH ) |
---|
74 | The IL image type must be IL(_UNSIGNED_)BYTE or IL_FLOAT. |
---|
75 | The IL image format must be IL_RGBA, IL_BGRA, IL_RGB, IL_BGR, IL_LUMINANCE or IL_LUMINANCE_ALPHA |
---|
76 | |
---|
77 | @param tar Target pointer |
---|
78 | @param ogrefmt Ogre pixel format to employ |
---|
79 | */ |
---|
80 | static void toOgre(const PixelBox &dst); |
---|
81 | |
---|
82 | /** Convert an OGRE format image to current IL image. |
---|
83 | @param src Pixelbox; encapsulates source pointer, width, height, |
---|
84 | depth and format |
---|
85 | */ |
---|
86 | static void fromOgre(const PixelBox &src); |
---|
87 | }; |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | #endif |
---|