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 (c) 2000-2005 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 #ifndef _PixelFormat_H__ 00026 #define _PixelFormat_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 #include "OgreCommon.h" 00030 00031 namespace Ogre { 00033 enum PixelFormat 00034 { 00036 PF_UNKNOWN = 0, 00038 PF_L8 = 1, 00039 PF_BYTE_L = PF_L8, 00041 PF_L16 = 2, 00042 PF_SHORT_L = PF_L16, 00044 PF_A8 = 3, 00045 PF_BYTE_A = PF_A8, 00047 PF_A4L4 = 4, 00049 PF_BYTE_LA = 5, 00051 PF_R5G6B5 = 6, 00053 PF_B5G6R5 = 7, 00055 PF_R3G3B2 = 31, 00057 PF_A4R4G4B4 = 8, 00059 PF_A1R5G5B5 = 9, 00061 PF_R8G8B8 = 10, 00063 PF_B8G8R8 = 11, 00065 PF_A8R8G8B8 = 12, 00067 PF_A8B8G8R8 = 13, 00069 PF_B8G8R8A8 = 14, 00071 PF_R8G8B8A8 = 28, 00074 PF_X8R8G8B8 = 26, 00077 PF_X8B8G8R8 = 27, 00078 #if OGRE_ENDIAN == OGRE_ENDIAN_BIG 00079 00080 PF_BYTE_RGB = PF_R8G8B8, 00082 PF_BYTE_BGR = PF_B8G8R8, 00084 PF_BYTE_BGRA = PF_B8G8R8A8, 00086 PF_BYTE_RGBA = PF_R8G8B8A8, 00087 #else 00088 00089 PF_BYTE_RGB = PF_B8G8R8, 00091 PF_BYTE_BGR = PF_R8G8B8, 00093 PF_BYTE_BGRA = PF_A8R8G8B8, 00095 PF_BYTE_RGBA = PF_A8B8G8R8, 00096 #endif 00097 00098 PF_A2R10G10B10 = 15, 00100 PF_A2B10G10R10 = 16, 00102 PF_DXT1 = 17, 00104 PF_DXT2 = 18, 00106 PF_DXT3 = 19, 00108 PF_DXT4 = 20, 00110 PF_DXT5 = 21, 00111 // 16-bit pixel format, 16 bits (float) for red 00112 PF_FLOAT16_R = 32, 00113 // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue 00114 PF_FLOAT16_RGB = 22, 00115 // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha 00116 PF_FLOAT16_RGBA = 23, 00117 // 16-bit pixel format, 16 bits (float) for red 00118 PF_FLOAT32_R = 33, 00119 // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue 00120 PF_FLOAT32_RGB = 24, 00121 // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha 00122 PF_FLOAT32_RGBA = 25, 00123 // Depth texture format 00124 PF_DEPTH = 29, 00125 // 64-bit pixel format, 16 bits for red, green, blue and alpha 00126 PF_SHORT_RGBA = 30, 00127 // Number of pixel formats currently defined 00128 PF_COUNT = 34 00129 }; 00130 00134 enum PixelFormatFlags { 00135 // This format has an alpha channel 00136 PFF_HASALPHA = 0x00000001, 00137 // This format is compressed. This invalidates the values in elemBytes, 00138 // elemBits and the bit counts as these might not be fixed in a compressed format. 00139 PFF_COMPRESSED = 0x00000002, 00140 // This is a floating point format 00141 PFF_FLOAT = 0x00000004, 00142 // This is a depth format (for depth textures) 00143 PFF_DEPTH = 0x00000008, 00144 // Format is in native endian. Generally true for the 16, 24 and 32 bits 00145 // formats which can be represented as machine integers. 00146 PFF_NATIVEENDIAN = 0x00000010, 00147 // This is an intensity format instead of a RGB one. The luminance 00148 // replaces R,G and B. (but not A) 00149 PFF_LUMINANCE = 0x00000020 00150 }; 00151 00153 enum PixelComponentType 00154 { 00155 PCT_BYTE = 0, 00156 PCT_SHORT = 1, 00157 PCT_FLOAT16 = 2, 00158 PCT_FLOAT32 = 3, 00159 PCT_COUNT = 4 00160 }; 00161 00167 class _OgreExport PixelBox: public Box { 00168 public: 00170 PixelBox() {} 00178 PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0): 00179 Box(extents), data(pixelData), format(pixelFormat) 00180 { 00181 setConsecutive(); 00182 } 00192 PixelBox(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0): 00193 Box(0, 0, 0, width, height, depth), 00194 data(pixelData), format(pixelFormat) 00195 { 00196 setConsecutive(); 00197 } 00198 00200 void *data; 00202 PixelFormat format; 00207 size_t rowPitch; 00213 size_t slicePitch; 00214 00218 void setConsecutive() 00219 { 00220 rowPitch = getWidth(); 00221 slicePitch = getWidth()*getHeight(); 00222 } 00227 size_t getRowSkip() const { return rowPitch - getWidth(); } 00232 size_t getSliceSkip() const { return slicePitch - (getHeight() * rowPitch); } 00233 00237 bool isConsecutive() const 00238 { 00239 return rowPitch == getWidth() && slicePitch == getWidth()*getHeight(); 00240 } 00244 size_t getConsecutiveSize() const; 00253 PixelBox getSubVolume(const Box &def) const; 00254 }; 00255 00256 00260 class _OgreExport PixelUtil { 00261 public: 00268 static size_t getNumElemBytes( PixelFormat format ); 00269 00276 static size_t getNumElemBits( PixelFormat format ); 00277 00295 static size_t getMemorySize(size_t width, size_t height, size_t depth, PixelFormat format); 00296 00304 static unsigned int getFlags( PixelFormat format ); 00305 00307 static bool hasAlpha(PixelFormat format); 00309 static bool isFloatingPoint(PixelFormat format); 00311 static bool isCompressed(PixelFormat format); 00313 static bool isDepth(PixelFormat format); 00315 static bool isNativeEndian(PixelFormat format); 00317 static bool isLuminance(PixelFormat format); 00318 00331 static bool isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format); 00332 00336 static void getBitDepths(PixelFormat format, int rgba[4]); 00337 00341 static void getBitMasks(PixelFormat format, uint32 rgba[4]); 00342 00345 static String getFormatName(PixelFormat srcformat); 00346 00354 static bool isAccessible(PixelFormat srcformat); 00355 00360 static PixelComponentType getComponentType(PixelFormat fmt); 00361 00365 static size_t getComponentCount(PixelFormat fmt); 00366 00372 static void packColour(const ColourValue &colour, const PixelFormat pf, const void* dest); 00378 static void packColour(const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, const void* dest); 00386 static void packColour(const float r, const float g, const float b, const float a, const PixelFormat pf, const void* dest); 00387 00393 static void unpackColour(ColourValue *colour, PixelFormat pf, const void* src); 00402 static void unpackColour(uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void* src); 00408 static void unpackColour(float *r, float *g, float *b, float *a, PixelFormat pf, const void* src); 00409 00418 static void bulkPixelConversion(void *src, PixelFormat srcFormat, void *dest, PixelFormat dstFormat, unsigned int count); 00419 00427 static void bulkPixelConversion(const PixelBox &src, const PixelBox &dst); 00428 }; 00429 00430 }; 00431 00432 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:46 2006