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-2005 The OGRE Team
|
---|
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 | */
|
---|
25 | #ifndef _Ogre_ILUtil_H__
|
---|
26 | #define _Ogre_ILUtil_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreCommon.h"
|
---|
30 | #include "OgrePixelFormat.h"
|
---|
31 |
|
---|
32 | namespace Ogre {
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * DevIL specific utility class
|
---|
36 | **/
|
---|
37 | class _OgrePrivate ILUtil {
|
---|
38 | public:
|
---|
39 | /// Structure that encapsulates a devIL image format definition
|
---|
40 | struct ILFormat {
|
---|
41 | /// Construct an invalidated ILFormat structure
|
---|
42 | ILFormat():
|
---|
43 | numberOfChannels(0), format(-1), type(-1) {};
|
---|
44 |
|
---|
45 | /// Construct a ILFormat from parameters
|
---|
46 | ILFormat(int channels, int format, int type=-1):
|
---|
47 | numberOfChannels(channels), format(format), type(type) {}
|
---|
48 |
|
---|
49 | /// Return wether this structure represents a valid DevIL format
|
---|
50 | bool isValid() { return format!=-1; }
|
---|
51 |
|
---|
52 | /// Number of channels, usually 3 or 4
|
---|
53 | int numberOfChannels;
|
---|
54 | /// IL_RGBA,IL_BGRA,IL_DXTx, ...
|
---|
55 | int format;
|
---|
56 | /// IL_UNSIGNED_BYTE, IL_UNSIGNED_SHORT, ... may be -1 for compressed formats
|
---|
57 | int type;
|
---|
58 | };
|
---|
59 |
|
---|
60 | /** Get OGRE format to which a given IL format can be most optimally converted.
|
---|
61 | */
|
---|
62 | static PixelFormat ilFormat2OgreFormat( int ImageFormat, int ImageType );
|
---|
63 | /** Get IL format that matches a given OGRE format exactly in memory.
|
---|
64 | @remarks Returns an invalid ILFormat (.isValid()==false) when
|
---|
65 | there is no IL format that matches this.
|
---|
66 | */
|
---|
67 | static ILFormat OgreFormat2ilFormat( PixelFormat format );
|
---|
68 | /** Convert current IL image to an OGRE format. The size of the target will be
|
---|
69 | PixelUtil::getNumElemBytes(fmt) * ilGetInteger( IL_IMAGE_WIDTH ) * ilGetInteger( IL_IMAGE_HEIGHT ) * ilGetInteger( IL_IMAGE_DEPTH )
|
---|
70 | The IL image type must be IL(_UNSIGNED_)BYTE or IL_FLOAT.
|
---|
71 | The IL image format must be IL_RGBA, IL_BGRA, IL_RGB, IL_BGR, IL_LUMINANCE or IL_LUMINANCE_ALPHA
|
---|
72 |
|
---|
73 | @param tar Target pointer
|
---|
74 | @param ogrefmt Ogre pixel format to employ
|
---|
75 | */
|
---|
76 | static void toOgre(const PixelBox &dst);
|
---|
77 |
|
---|
78 | /** Convert an OGRE format image to current IL image.
|
---|
79 | @param src Pixelbox; encapsulates source pointer, width, height,
|
---|
80 | depth and format
|
---|
81 | */
|
---|
82 | static void fromOgre(const PixelBox &src);
|
---|
83 | };
|
---|
84 |
|
---|
85 | }
|
---|
86 |
|
---|
87 | #endif
|
---|