00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreStableHeaders.h" 00026 #include "OgrePrerequisites.h" 00027 #include "OgreCommon.h" 00028 00029 #include <IL/il.h> 00030 00031 namespace Ogre 00032 { 00033 PixelFormat ilFormat2OgreFormat( int ImageFormat, int BytesPerPixel ) 00034 { 00035 switch( BytesPerPixel ) 00036 { 00037 case 1: 00038 return PF_L8; 00039 00040 case 2: 00041 switch( ImageFormat ) 00042 { 00043 case IL_BGR: 00044 return PF_B5G6R5; 00045 case IL_RGB: 00046 return PF_R5G6B5; 00047 case IL_BGRA: 00048 return PF_B4G4R4A4; 00049 case IL_RGBA: 00050 return PF_A4R4G4B4; 00051 } 00052 00053 case 3: 00054 switch( ImageFormat ) 00055 { 00056 case IL_BGR: 00057 return PF_B8G8R8; 00058 case IL_RGB: 00059 return PF_R8G8B8; 00060 } 00061 00062 case 4: 00063 switch( ImageFormat ) 00064 { 00065 case IL_BGRA: 00066 return PF_B8G8R8A8; 00067 case IL_RGBA: 00068 return PF_A8R8G8B8; 00069 case IL_DXT1: 00070 return PF_DXT1; 00071 case IL_DXT2: 00072 return PF_DXT2; 00073 case IL_DXT3: 00074 return PF_DXT3; 00075 case IL_DXT4: 00076 return PF_DXT4; 00077 case IL_DXT5: 00078 return PF_DXT5; 00079 } 00080 00081 default: 00082 return PF_UNKNOWN; 00083 } 00084 00085 } 00086 00087 std::pair< int, int > OgreFormat2ilFormat( PixelFormat format ) 00088 { 00089 switch( format ) 00090 { 00091 case PF_L8: 00092 case PF_A8: 00093 return std::pair< int, int >( IL_LUMINANCE, 1 ); 00094 case PF_R5G6B5: 00095 return std::pair< int, int >( IL_RGB, 2 ); 00096 case PF_B5G6R5: 00097 return std::pair< int, int >( IL_BGR, 2 ); 00098 case PF_A4R4G4B4: 00099 return std::pair< int, int >( IL_RGBA, 2 ); 00100 case PF_B4G4R4A4: 00101 return std::pair< int, int >( IL_BGRA, 2 ); 00102 case PF_R8G8B8: 00103 return std::pair< int, int >( IL_RGB, 3 ); 00104 case PF_B8G8R8: 00105 return std::pair< int, int >( IL_BGR, 3 ); 00106 case PF_A8R8G8B8: 00107 return std::pair< int, int >( IL_RGBA, 4 ); 00108 case PF_B8G8R8A8: 00109 return std::pair< int, int >( IL_BGRA, 4 ); 00110 case PF_UNKNOWN: 00111 case PF_A4L4: 00112 case PF_L4A4: 00113 case PF_A2R10G10B10: 00114 case PF_B10G10R10A2: 00115 default: 00116 return std::pair< int, int >( -1, -1 ); 00117 } 00118 } 00119 }
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:21:57 2004