Bladeren bron

Moved more headers to CamelotUtility

Marko Pintera 13 jaren geleden
bovenliggende
commit
bd80ef90ba

+ 0 - 3
CamelotRenderer/CamelotRenderer.vcxproj

@@ -95,7 +95,6 @@
     <ClInclude Include="CmD3D9RenderSystemFactory.h" />
     <ClInclude Include="CmRenderSystemFactory.h" />
     <ClInclude Include="CmRenderSystemManager.h" />
-    <ClInclude Include="CmBitwise.h" />
     <ClInclude Include="CmCamera.h" />
     <ClInclude Include="CmCommon.h" />
     <ClInclude Include="CmConfigOptionMap.h" />
@@ -137,7 +136,6 @@
     <ClInclude Include="CmHardwareVertexBuffer.h" />
     <ClInclude Include="CmHighLevelGpuProgram.h" />
     <ClInclude Include="CmHighLevelGpuProgramManager.h" />
-    <ClInclude Include="CmPixelUtil.h" />
     <ClInclude Include="CmPrerequisites.h" />
     <ClInclude Include="CmRenderOperation.h" />
     <ClInclude Include="CmRenderSystem.h" />
@@ -236,7 +234,6 @@
     <ClCompile Include="CmHardwareVertexBuffer.cpp" />
     <ClCompile Include="CmHighLevelGpuProgram.cpp" />
     <ClCompile Include="CmHighLevelGpuProgramManager.cpp" />
-    <ClCompile Include="CmPixelUtil.cpp" />
     <ClCompile Include="CmRenderSystem.cpp" />
     <ClCompile Include="CmRenderSystemCapabilities.cpp" />
     <ClCompile Include="CmRenderTarget.cpp" />

+ 0 - 9
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -338,9 +338,6 @@
     <ClInclude Include="RenderSystemGL\Include\CmWin32Window.h">
       <Filter>RenderSystemGL\Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="CmBitwise.h">
-      <Filter>Header Files\ForRemoval</Filter>
-    </ClInclude>
     <ClInclude Include="CmConfigOptionMap.h">
       <Filter>Header Files\ForRemoval</Filter>
     </ClInclude>
@@ -359,9 +356,6 @@
     <ClInclude Include="CmWindowEventUtilities.h">
       <Filter>Header Files\Utility</Filter>
     </ClInclude>
-    <ClInclude Include="CmPixelUtil.h">
-      <Filter>Header Files\Utility</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">
@@ -631,8 +625,5 @@
     <ClCompile Include="CmWindowEventUtilities.cpp">
       <Filter>Source Files\Utility</Filter>
     </ClCompile>
-    <ClCompile Include="CmPixelUtil.cpp">
-      <Filter>Source Files\Utility</Filter>
-    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 331
CamelotRenderer/CmBitwise.h

@@ -1,331 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef _Bitwise_H__
-#define _Bitwise_H__
-
-#include "CmPrerequisites.h"
-
-namespace CamelotEngine {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Math
-	*  @{
-	*/
-
-    /** Class for manipulating bit patterns.
-    */
-    class Bitwise {
-    public:
-        /** Returns the most significant bit set in a value.
-        */
-        static FORCEINLINE unsigned int mostSignificantBitSet(unsigned int value)
-        {
-            unsigned int result = 0;
-            while (value != 0) {
-                ++result;
-                value >>= 1;
-            }
-            return result-1;
-        }
-        /** Returns the closest power-of-two number greater or equal to value.
-            @note 0 and 1 are powers of two, so 
-                firstPO2From(0)==0 and firstPO2From(1)==1.
-        */
-        static FORCEINLINE UINT32 firstPO2From(UINT32 n)
-        {
-            --n;            
-            n |= n >> 16;
-            n |= n >> 8;
-            n |= n >> 4;
-            n |= n >> 2;
-            n |= n >> 1;
-            ++n;
-            return n;
-        }
-        /** Determines whether the number is power-of-two or not.
-            @note 0 and 1 are tread as power of two.
-        */
-        template<typename T>
-        static FORCEINLINE bool isPO2(T n)
-        {
-            return (n & (n-1)) == 0;
-        }
-        /** Returns the number of bits a pattern must be shifted right by to
-            remove right-hand zeros.
-        */
-		template<typename T>
-        static FORCEINLINE unsigned int getBitShift(T mask)
-		{
-			if (mask == 0)
-				return 0;
-
-			unsigned int result = 0;
-			while ((mask & 1) == 0) {
-				++result;
-				mask >>= 1;
-			}
-			return result;
-		}
-
-        /** Takes a value with a given src bit mask, and produces another
-            value with a desired bit mask.
-            @remarks
-                This routine is useful for colour conversion.
-        */
-		template<typename SrcT, typename DestT>
-        static inline DestT convertBitPattern(SrcT srcValue, SrcT srcBitMask, DestT destBitMask)
-		{
-			// Mask off irrelevant source value bits (if any)
-			srcValue = srcValue & srcBitMask;
-
-			// Shift source down to bottom of DWORD
-			const unsigned int srcBitShift = getBitShift(srcBitMask);
-			srcValue >>= srcBitShift;
-
-			// Get max value possible in source from srcMask
-			const SrcT srcMax = srcBitMask >> srcBitShift;
-
-			// Get max available in dest
-			const unsigned int destBitShift = getBitShift(destBitMask);
-			const DestT destMax = destBitMask >> destBitShift;
-
-			// Scale source value into destination, and shift back
-			DestT destValue = (srcValue * destMax) / srcMax;
-			return (destValue << destBitShift);
-		}
-
-        /**
-         * Convert N bit colour channel value to P bits. It fills P bits with the
-         * bit pattern repeated. (this is /((1<<n)-1) in fixed point)
-         */
-        static inline unsigned int fixedToFixed(UINT32 value, unsigned int n, unsigned int p) 
-        {
-            if(n > p) 
-            {
-                // Less bits required than available; this is easy
-                value >>= n-p;
-            } 
-            else if(n < p)
-            {
-                // More bits required than are there, do the fill
-                // Use old fashioned division, probably better than a loop
-                if(value == 0)
-                        value = 0;
-                else if(value == (static_cast<unsigned int>(1)<<n)-1)
-                        value = (1<<p)-1;
-                else    value = value*(1<<p)/((1<<n)-1);
-            }
-            return value;    
-        }
-
-        /**
-         * Convert floating point colour channel value between 0.0 and 1.0 (otherwise clamped) 
-         * to integer of a certain number of bits. Works for any value of bits between 0 and 31.
-         */
-        static inline unsigned int floatToFixed(const float value, const unsigned int bits)
-        {
-            if(value <= 0.0f) return 0;
-            else if (value >= 1.0f) return (1<<bits)-1;
-            else return (unsigned int)(value * (1<<bits));     
-        }
-
-        /**
-         * Fixed point to float
-         */
-        static inline float fixedToFloat(unsigned value, unsigned int bits)
-        {
-            return (float)value/(float)((1<<bits)-1);
-        }
-
-        /**
-         * Write a n*8 bits integer value to memory in native endian.
-         */
-        static inline void intWrite(void *dest, const int n, const unsigned int value)
-        {
-            switch(n) {
-                case 1:
-                    ((UINT8*)dest)[0] = (UINT8)value;
-                    break;
-                case 2:
-                    ((UINT16*)dest)[0] = (UINT16)value;
-                    break;
-                case 3:
-#if CM_ENDIAN == CM_ENDIAN_BIG      
-                    ((UINT8*)dest)[0] = (UINT8)((value >> 16) & 0xFF);
-                    ((UINT8*)dest)[1] = (UINT8)((value >> 8) & 0xFF);
-                    ((UINT8*)dest)[2] = (UINT8)(value & 0xFF);
-#else
-                    ((UINT8*)dest)[2] = (UINT8)((value >> 16) & 0xFF);
-                    ((UINT8*)dest)[1] = (UINT8)((value >> 8) & 0xFF);
-                    ((UINT8*)dest)[0] = (UINT8)(value & 0xFF);
-#endif
-                    break;
-                case 4:
-                    ((UINT32*)dest)[0] = (UINT32)value;                
-                    break;                
-            }        
-        }
-        /**
-         * Read a n*8 bits integer value to memory in native endian.
-         */
-        static inline unsigned int intRead(const void *src, int n) {
-            switch(n) {
-                case 1:
-                    return ((UINT8*)src)[0];
-                case 2:
-                    return ((UINT16*)src)[0];
-                case 3:
-#if CM_ENDIAN == CM_ENDIAN_BIG      
-                    return ((UINT32)((UINT8*)src)[0]<<16)|
-                            ((UINT32)((UINT8*)src)[1]<<8)|
-                            ((UINT32)((UINT8*)src)[2]);
-#else
-                    return ((UINT32)((UINT8*)src)[0])|
-                            ((UINT32)((UINT8*)src)[1]<<8)|
-                            ((UINT32)((UINT8*)src)[2]<<16);
-#endif
-                case 4:
-                    return ((UINT32*)src)[0];
-            } 
-            return 0; // ?
-        }
-
-        /** Convert a float32 to a float16 (NV_half_float)
-         	Courtesy of OpenEXR
-        */
-        static inline UINT16 floatToHalf(float i)
-        {
-            union { float f; UINT32 i; } v;
-            v.f = i;
-            return floatToHalfI(v.i);
-        }
-		/** Converts float in UINT32 format to a a half in UINT16 format
-		*/
-        static inline UINT16 floatToHalfI(UINT32 i)
-        {
-            register int s =  (i >> 16) & 0x00008000;
-            register int e = ((i >> 23) & 0x000000ff) - (127 - 15);
-            register int m =   i        & 0x007fffff;
-        
-            if (e <= 0)
-            {
-                if (e < -10)
-                {
-                    return 0;
-                }
-                m = (m | 0x00800000) >> (1 - e);
-        
-                return static_cast<UINT16>(s | (m >> 13));
-            }
-            else if (e == 0xff - (127 - 15))
-            {
-                if (m == 0) // Inf
-                {
-                    return static_cast<UINT16>(s | 0x7c00);
-                } 
-                else    // NAN
-                {
-                    m >>= 13;
-                    return static_cast<UINT16>(s | 0x7c00 | m | (m == 0));
-                }
-            }
-            else
-            {
-                if (e > 30) // Overflow
-                {
-                    return static_cast<UINT16>(s | 0x7c00);
-                }
-        
-                return static_cast<UINT16>(s | (e << 10) | (m >> 13));
-            }
-        }
-        
-        /**
-         * Convert a float16 (NV_half_float) to a float32
-         * Courtesy of OpenEXR
-         */
-        static inline float halfToFloat(UINT16 y)
-        {
-            union { float f; UINT32 i; } v;
-            v.i = halfToFloatI(y);
-            return v.f;
-        }
-		/** Converts a half in UINT16 format to a float
-		 	in UINT32 format
-		 */
-        static inline UINT32 halfToFloatI(UINT16 y)
-        {
-            register int s = (y >> 15) & 0x00000001;
-            register int e = (y >> 10) & 0x0000001f;
-            register int m =  y        & 0x000003ff;
-        
-            if (e == 0)
-            {
-                if (m == 0) // Plus or minus zero
-                {
-                    return s << 31;
-                }
-                else // Denormalized number -- renormalize it
-                {
-                    while (!(m & 0x00000400))
-                    {
-                        m <<= 1;
-                        e -=  1;
-                    }
-        
-                    e += 1;
-                    m &= ~0x00000400;
-                }
-            }
-            else if (e == 31)
-            {
-                if (m == 0) // Inf
-                {
-                    return (s << 31) | 0x7f800000;
-                }
-                else // NaN
-                {
-                    return (s << 31) | 0x7f800000 | (m << 13);
-                }
-            }
-        
-            e = e + (127 - 15);
-            m = m << 13;
-        
-            return (s << 31) | (e << 23) | m;
-        }
-         
-
-    };
-	/** @} */
-	/** @} */
-
-}
-
-#endif

+ 0 - 69
CamelotRenderer/CmCommon.h

@@ -196,75 +196,6 @@ namespace CamelotEngine {
 	/// Name / value parameter pair (first = name, second = value)
 	typedef map<String, String>::type NameValuePairList;
 
-    /** Structure used to define a box in a 3-D integer space.
-        Note that the left, top, and front edges are included but the right, 
-        bottom and back ones are not.
-        */
-    struct Box
-    {
-        size_t left, top, right, bottom, front, back;
-		/// Parameterless constructor for setting the members manually
-        Box()
-			: left(0), top(0), right(1), bottom(1), front(0), back(1)
-        {
-        }
-        /** Define a box from left, top, right and bottom coordinates
-            This box will have depth one (front=0 and back=1).
-            @param	l	x value of left edge
-            @param	t	y value of top edge
-            @param	r	x value of right edge
-            @param	b	y value of bottom edge
-            @note Note that the left, top, and front edges are included 
- 		        but the right, bottom and back ones are not.
-        */
-        Box( size_t l, size_t t, size_t r, size_t b ):
-            left(l),
-            top(t),   
-            right(r),
-            bottom(b),
-            front(0),
-            back(1)
-        {
-          	assert(right >= left && bottom >= top && back >= front);
-        }
-        /** Define a box from left, top, front, right, bottom and back
-            coordinates.
-            @param	l	x value of left edge
-            @param	t	y value of top edge
-            @param  ff  z value of front edge
-            @param	r	x value of right edge
-            @param	b	y value of bottom edge
-            @param  bb  z value of back edge
-            @note Note that the left, top, and front edges are included 
- 		        but the right, bottom and back ones are not.
-        */
-        Box( size_t l, size_t t, size_t ff, size_t r, size_t b, size_t bb ):
-            left(l),
-            top(t),   
-            right(r),
-            bottom(b),
-            front(ff),
-            back(bb)
-        {
-          	assert(right >= left && bottom >= top && back >= front);
-        }
-            
-        /// Return true if the other box is a part of this one
-        bool contains(const Box &def) const
-        {
-            return (def.left >= left && def.top >= top && def.front >= front &&
-				def.right <= right && def.bottom <= bottom && def.back <= back);
-        }
-            
-        /// Get the width of this box
-        size_t getWidth() const { return right-left; }
-        /// Get the height of this box
-        size_t getHeight() const { return bottom-top; }
-        /// Get the depth of this box
-        size_t getDepth() const { return back-front; }
-    };
-
-
 	/// Render window creation parameters.
 	struct RenderWindowDescription
 	{

+ 0 - 1790
CamelotRenderer/CmPixelUtil.cpp

@@ -1,1790 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#include "CmPixelUtil.h"
-#include "CmBitwise.h"
-#include "CmColor.h"
-#include "CmException.h"
-
-
-namespace CamelotEngine {
-
-	//-----------------------------------------------------------------------
-    /**
-    * Resamplers
-    */
-
-	// variable name hints:
-	// sx_48 = 16/48-bit fixed-point x-position in source
-	// stepx = difference between adjacent sx_48 values
-	// sx1 = lower-bound integer x-position in source
-	// sx2 = upper-bound integer x-position in source
-	// sxf = fractional weight beween sx1 and sx2
-	// x,y,z = location of output pixel in destination
-
-	// nearest-neighbor resampler, does not convert formats.
-	// templated on bytes-per-pixel to allow compiler optimizations, such
-	// as simplifying memcpy() and replacing multiplies with bitshifts
-	template<unsigned int elemsize> struct NearestResampler {
-		static void scale(const PixelData& src, const PixelData& dst) {
-			// assert(src.format == dst.format);
-
-			// srcdata stays at beginning, pdst is a moving pointer
-			UINT8* srcdata = (UINT8*)src.data;
-			UINT8* pdst = (UINT8*)dst.data;
-
-			// sx_48,sy_48,sz_48 represent current position in source
-			// using 16/48-bit fixed precision, incremented by steps
-			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-
-			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-			// for the center of the destination pixel, not the top-left corner
-			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48 += stepz) {
-				size_t srczoff = (size_t)(sz_48 >> 48) * src.slicePitch;
-
-				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48 += stepy) {
-					size_t srcyoff = (size_t)(sy_48 >> 48) * src.rowPitch;
-
-					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48 += stepx) {
-						UINT8* psrc = srcdata +
-							elemsize*((size_t)(sx_48 >> 48) + srcyoff + srczoff);
-						memcpy(pdst, psrc, elemsize);
-						pdst += elemsize;
-					}
-					pdst += elemsize*dst.getRowSkip();
-				}
-				pdst += elemsize*dst.getSliceSkip();
-			}
-		}
-	};
-
-
-	// default floating-point linear resampler, does format conversion
-	struct LinearResampler {
-		static void scale(const PixelData& src, const PixelData& dst) {
-			size_t srcelemsize = PixelUtil::getNumElemBytes(src.format);
-			size_t dstelemsize = PixelUtil::getNumElemBytes(dst.format);
-
-			// srcdata stays at beginning, pdst is a moving pointer
-			UINT8* srcdata = (UINT8*)src.data;
-			UINT8* pdst = (UINT8*)dst.data;
-
-			// sx_48,sy_48,sz_48 represent current position in source
-			// using 16/48-bit fixed precision, incremented by steps
-			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-
-			// temp is 16/16 bit fixed precision, used to adjust a source
-			// coordinate (x, y, or z) backwards by half a pixel so that the
-			// integer bits represent the first sample (eg, sx1) and the
-			// fractional bits are the blend weight of the second sample
-			unsigned int temp;
-
-			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-			// for the center of the destination pixel, not the top-left corner
-			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
-				temp = static_cast<unsigned int>(sz_48 >> 32);
-				temp = (temp > 0x8000)? temp - 0x8000 : 0;
-				size_t sz1 = temp >> 16;				 // src z, sample #1
-				size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
-				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
-
-				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-					temp = static_cast<unsigned int>(sy_48 >> 32);
-					temp = (temp > 0x8000)? temp - 0x8000 : 0;
-					size_t sy1 = temp >> 16;					// src y #1
-					size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
-					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
-
-					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-						temp = static_cast<unsigned int>(sx_48 >> 32);
-						temp = (temp > 0x8000)? temp - 0x8000 : 0;
-						size_t sx1 = temp >> 16;					// src x #1
-						size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
-						float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
-
-						Color x1y1z1, x2y1z1, x1y2z1, x2y2z1;
-						Color x1y1z2, x2y1z2, x1y2z2, x2y2z2;
-
-#define UNPACK(dst,x,y,z) PixelUtil::unpackColour(&dst, src.format, \
-	srcdata + srcelemsize*((x)+(y)*src.rowPitch+(z)*src.slicePitch))
-
-						UNPACK(x1y1z1,sx1,sy1,sz1); UNPACK(x2y1z1,sx2,sy1,sz1);
-						UNPACK(x1y2z1,sx1,sy2,sz1); UNPACK(x2y2z1,sx2,sy2,sz1);
-						UNPACK(x1y1z2,sx1,sy1,sz2); UNPACK(x2y1z2,sx2,sy1,sz2);
-						UNPACK(x1y2z2,sx1,sy2,sz2); UNPACK(x2y2z2,sx2,sy2,sz2);
-#undef UNPACK
-
-						Color accum =
-							x1y1z1 * ((1.0f - sxf)*(1.0f - syf)*(1.0f - szf)) +
-							x2y1z1 * (        sxf *(1.0f - syf)*(1.0f - szf)) +
-							x1y2z1 * ((1.0f - sxf)*        syf *(1.0f - szf)) +
-							x2y2z1 * (        sxf *        syf *(1.0f - szf)) +
-							x1y1z2 * ((1.0f - sxf)*(1.0f - syf)*        szf ) +
-							x2y1z2 * (        sxf *(1.0f - syf)*        szf ) +
-							x1y2z2 * ((1.0f - sxf)*        syf *        szf ) +
-							x2y2z2 * (        sxf *        syf *        szf );
-
-						PixelUtil::packColour(accum, dst.format, pdst);
-
-						pdst += dstelemsize;
-					}
-					pdst += dstelemsize*dst.getRowSkip();
-				}
-				pdst += dstelemsize*dst.getSliceSkip();
-			}
-		}
-	};
-
-
-	// float32 linear resampler, converts FLOAT32_RGB/FLOAT32_RGBA only.
-	// avoids overhead of pixel unpack/repack function calls
-	struct LinearResampler_Float32 {
-		static void scale(const PixelData& src, const PixelData& dst) {
-			size_t srcchannels = PixelUtil::getNumElemBytes(src.format) / sizeof(float);
-			size_t dstchannels = PixelUtil::getNumElemBytes(dst.format) / sizeof(float);
-			// assert(srcchannels == 3 || srcchannels == 4);
-			// assert(dstchannels == 3 || dstchannels == 4);
-
-			// srcdata stays at beginning, pdst is a moving pointer
-			float* srcdata = (float*)src.data;
-			float* pdst = (float*)dst.data;
-
-			// sx_48,sy_48,sz_48 represent current position in source
-			// using 16/48-bit fixed precision, incremented by steps
-			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-			UINT64 stepz = ((UINT64)src.getDepth() << 48) / dst.getDepth();
-
-			// temp is 16/16 bit fixed precision, used to adjust a source
-			// coordinate (x, y, or z) backwards by half a pixel so that the
-			// integer bits represent the first sample (eg, sx1) and the
-			// fractional bits are the blend weight of the second sample
-			unsigned int temp;
-
-			// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
-			// for the center of the destination pixel, not the top-left corner
-			UINT64 sz_48 = (stepz >> 1) - 1;
-			for (size_t z = dst.front; z < dst.back; z++, sz_48+=stepz) {
-				temp = static_cast<unsigned int>(sz_48 >> 32);
-				temp = (temp > 0x8000)? temp - 0x8000 : 0;
-				size_t sz1 = temp >> 16;				 // src z, sample #1
-				size_t sz2 = std::min(sz1+1,src.getDepth()-1);// src z, sample #2
-				float szf = (temp & 0xFFFF) / 65536.f; // weight of sample #2
-
-				UINT64 sy_48 = (stepy >> 1) - 1;
-				for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-					temp = static_cast<unsigned int>(sy_48 >> 32);
-					temp = (temp > 0x8000)? temp - 0x8000 : 0;
-					size_t sy1 = temp >> 16;					// src y #1
-					size_t sy2 = std::min(sy1+1,src.getHeight()-1);// src y #2
-					float syf = (temp & 0xFFFF) / 65536.f; // weight of #2
-
-					UINT64 sx_48 = (stepx >> 1) - 1;
-					for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-						temp = static_cast<unsigned int>(sx_48 >> 32);
-						temp = (temp > 0x8000)? temp - 0x8000 : 0;
-						size_t sx1 = temp >> 16;					// src x #1
-						size_t sx2 = std::min(sx1+1,src.getWidth()-1);// src x #2
-						float sxf = (temp & 0xFFFF) / 65536.f; // weight of #2
-
-						// process R,G,B,A simultaneously for cache coherence?
-						float accum[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-
-#define ACCUM3(x,y,z,factor) \
-						{ float f = factor; \
-						size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
-						accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
-						accum[2]+=srcdata[off+2]*f; }
-
-#define ACCUM4(x,y,z,factor) \
-						{ float f = factor; \
-						size_t off = (x+y*src.rowPitch+z*src.slicePitch)*srcchannels; \
-						accum[0]+=srcdata[off+0]*f; accum[1]+=srcdata[off+1]*f; \
-						accum[2]+=srcdata[off+2]*f; accum[3]+=srcdata[off+3]*f; }
-
-						if (srcchannels == 3 || dstchannels == 3) {
-							// RGB, no alpha
-							ACCUM3(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
-							ACCUM3(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
-							ACCUM3(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
-							ACCUM3(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
-							ACCUM3(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
-							ACCUM3(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
-							ACCUM3(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
-							ACCUM3(sx2,sy2,sz2,      sxf *      syf *      szf );
-							accum[3] = 1.0f;
-						} else {
-							// RGBA
-							ACCUM4(sx1,sy1,sz1,(1.0f-sxf)*(1.0f-syf)*(1.0f-szf));
-							ACCUM4(sx2,sy1,sz1,      sxf *(1.0f-syf)*(1.0f-szf));
-							ACCUM4(sx1,sy2,sz1,(1.0f-sxf)*      syf *(1.0f-szf));
-							ACCUM4(sx2,sy2,sz1,      sxf *      syf *(1.0f-szf));
-							ACCUM4(sx1,sy1,sz2,(1.0f-sxf)*(1.0f-syf)*      szf );
-							ACCUM4(sx2,sy1,sz2,      sxf *(1.0f-syf)*      szf );
-							ACCUM4(sx1,sy2,sz2,(1.0f-sxf)*      syf *      szf );
-							ACCUM4(sx2,sy2,sz2,      sxf *      syf *      szf );
-						}
-
-						memcpy(pdst, accum, sizeof(float)*dstchannels);
-
-#undef ACCUM3
-#undef ACCUM4
-
-						pdst += dstchannels;
-					}
-					pdst += dstchannels*dst.getRowSkip();
-				}
-				pdst += dstchannels*dst.getSliceSkip();
-			}
-		}
-	};
-
-
-
-	// byte linear resampler, does not do any format conversions.
-	// only handles pixel formats that use 1 byte per color channel.
-	// 2D only; punts 3D pixelboxes to default LinearResampler (slow).
-	// templated on bytes-per-pixel to allow compiler optimizations, such
-	// as unrolling loops and replacing multiplies with bitshifts
-	template<unsigned int channels> struct LinearResampler_Byte {
-		static void scale(const PixelData& src, const PixelData& dst) {
-			// assert(src.format == dst.format);
-
-			// only optimized for 2D
-			if (src.getDepth() > 1 || dst.getDepth() > 1) {
-				LinearResampler::scale(src, dst);
-				return;
-			}
-
-			// srcdata stays at beginning of slice, pdst is a moving pointer
-			UINT8* srcdata = (UINT8*)src.data;
-			UINT8* pdst = (UINT8*)dst.data;
-
-			// sx_48,sy_48 represent current position in source
-			// using 16/48-bit fixed precision, incremented by steps
-			UINT64 stepx = ((UINT64)src.getWidth() << 48) / dst.getWidth();
-			UINT64 stepy = ((UINT64)src.getHeight() << 48) / dst.getHeight();
-
-			// bottom 28 bits of temp are 16/12 bit fixed precision, used to
-			// adjust a source coordinate backwards by half a pixel so that the
-			// integer bits represent the first sample (eg, sx1) and the
-			// fractional bits are the blend weight of the second sample
-			unsigned int temp;
-
-			UINT64 sy_48 = (stepy >> 1) - 1;
-			for (size_t y = dst.top; y < dst.bottom; y++, sy_48+=stepy) {
-				temp = static_cast<unsigned int>(sy_48 >> 36);
-				temp = (temp > 0x800)? temp - 0x800: 0;
-				unsigned int syf = temp & 0xFFF;
-				size_t sy1 = temp >> 12;
-				size_t sy2 = std::min(sy1+1, src.bottom-src.top-1);
-				size_t syoff1 = sy1 * src.rowPitch;
-				size_t syoff2 = sy2 * src.rowPitch;
-
-				UINT64 sx_48 = (stepx >> 1) - 1;
-				for (size_t x = dst.left; x < dst.right; x++, sx_48+=stepx) {
-					temp = static_cast<unsigned int>(sx_48 >> 36);
-					temp = (temp > 0x800)? temp - 0x800 : 0;
-					unsigned int sxf = temp & 0xFFF;
-					size_t sx1 = temp >> 12;
-					size_t sx2 = std::min(sx1+1, src.right-src.left-1);
-
-					unsigned int sxfsyf = sxf*syf;
-					for (unsigned int k = 0; k < channels; k++) {
-						unsigned int accum =
-							srcdata[(sx1 + syoff1)*channels+k]*(0x1000000-(sxf<<12)-(syf<<12)+sxfsyf) +
-							srcdata[(sx2 + syoff1)*channels+k]*((sxf<<12)-sxfsyf) +
-							srcdata[(sx1 + syoff2)*channels+k]*((syf<<12)-sxfsyf) +
-							srcdata[(sx2 + syoff2)*channels+k]*sxfsyf;
-						// accum is computed using 8/24-bit fixed-point math
-						// (maximum is 0xFF000000; rounding will not cause overflow)
-						*pdst++ = static_cast<UINT8>((accum + 0x800000) >> 24);
-					}
-				}
-				pdst += channels*dst.getRowSkip();
-			}
-		}
-	};
-
-    //-----------------------------------------------------------------------
-    /**
-    * A record that describes a pixel format in detail.
-    */
-    struct PixelFormatDescription {
-        /* Name of the format, as in the enum */
-        const char *name;
-        /* Number of bytes one element (colour value) takes. */
-        unsigned char elemBytes;
-        /* Pixel format flags, see enum PixelFormatFlags for the bit field
-        * definitions
-        */
-        UINT32 flags;
-        /** Component type
-         */
-        PixelComponentType componentType;
-        /** Component count
-         */
-        unsigned char componentCount;
-        /* Number of bits for red(or luminance), green, blue, alpha
-        */
-        unsigned char rbits,gbits,bbits,abits; /*, ibits, dbits, ... */
-
-        /* Masks and shifts as used by packers/unpackers */
-        UINT32 rmask, gmask, bmask, amask;
-        unsigned char rshift, gshift, bshift, ashift;
-    };
-    //-----------------------------------------------------------------------
-    /** Pixel format database */
-    PixelFormatDescription _pixelFormats[PF_COUNT] = {
-	//-----------------------------------------------------------------------
-        {"PF_UNKNOWN",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        0,
-        /* Component type and count */
-        PCT_BYTE, 0,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_L8",
-        /* Bytes per element */
-        1,
-        /* Flags */
-        PFF_LUMINANCE | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 1,
-        /* rbits, gbits, bbits, abits */
-        8, 0, 0, 0,
-        /* Masks and shifts */
-        0xFF, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_L16",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_LUMINANCE | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_SHORT, 1,
-        /* rbits, gbits, bbits, abits */
-        16, 0, 0, 0,
-        /* Masks and shifts */
-        0xFFFF, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A8",
-        /* Bytes per element */
-        1,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 1,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 8,
-        /* Masks and shifts */
-        0, 0, 0, 0xFF, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A4L4",
-        /* Bytes per element */
-        1,
-        /* Flags */
-        PFF_HASALPHA | PFF_LUMINANCE | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 2,
-        /* rbits, gbits, bbits, abits */
-        4, 0, 0, 4,
-        /* Masks and shifts */
-        0x0F, 0, 0, 0xF0, 0, 0, 0, 4
-        },
-	//-----------------------------------------------------------------------
-        {"PF_BYTE_LA",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_HASALPHA | PFF_LUMINANCE,
-        /* Component type and count */
-        PCT_BYTE, 2,
-        /* rbits, gbits, bbits, abits */
-        8, 0, 0, 8,
-        /* Masks and shifts */
-        0,0,0,0,0,0,0,0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_R5G6B5",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        5, 6, 5, 0,
-        /* Masks and shifts */
-        0xF800, 0x07E0, 0x001F, 0,
-        11, 5, 0, 0
-        },
-	//-----------------------------------------------------------------------
-		{"PF_B5G6R5",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        5, 6, 5, 0,
-        /* Masks and shifts */
-        0x001F, 0x07E0, 0xF800, 0,
-        0, 5, 11, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A4R4G4B4",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        4, 4, 4, 4,
-        /* Masks and shifts */
-        0x0F00, 0x00F0, 0x000F, 0xF000,
-        8, 4, 0, 12
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A1R5G5B5",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        5, 5, 5, 1,
-        /* Masks and shifts */
-        0x7C00, 0x03E0, 0x001F, 0x8000,
-        10, 5, 0, 15,
-        },
-	//-----------------------------------------------------------------------
-        {"PF_R8G8B8",
-        /* Bytes per element */
-        3,  // 24 bit integer -- special
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 0,
-        /* Masks and shifts */
-        0xFF0000, 0x00FF00, 0x0000FF, 0,
-        16, 8, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_B8G8R8",
-        /* Bytes per element */
-        3,  // 24 bit integer -- special
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 0,
-        /* Masks and shifts */
-        0x0000FF, 0x00FF00, 0xFF0000, 0,
-        0, 8, 16, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A8R8G8B8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 8,
-        /* Masks and shifts */
-        0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
-        16, 8, 0, 24
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A8B8G8R8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 8,
-        /* Masks and shifts */
-        0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000,
-        0, 8, 16, 24,
-        },
-	//-----------------------------------------------------------------------
-        {"PF_B8G8R8A8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 8,
-        /* Masks and shifts */
-        0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF,
-        8, 16, 24, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A2R10G10B10",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        10, 10, 10, 2,
-        /* Masks and shifts */
-        0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000,
-        20, 10, 0, 30
-        },
-	//-----------------------------------------------------------------------
-        {"PF_A2B10G10R10",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        10, 10, 10, 2,
-        /* Masks and shifts */
-        0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000,
-        0, 10, 20, 30
-        },
-	//-----------------------------------------------------------------------
-        {"PF_DXT1",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 3, // No alpha
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_DXT2",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_DXT3",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_DXT4",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_DXT5",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT16_RGB",
-        /* Bytes per element */
-        6,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT16, 3,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 16, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT16_RGBA",
-        /* Bytes per element */
-        8,
-        /* Flags */
-        PFF_FLOAT | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_FLOAT16, 4,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 16, 16,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT32_RGB",
-        /* Bytes per element */
-        12,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT32, 3,
-        /* rbits, gbits, bbits, abits */
-        32, 32, 32, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT32_RGBA",
-        /* Bytes per element */
-        16,
-        /* Flags */
-        PFF_FLOAT | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_FLOAT32, 4,
-        /* rbits, gbits, bbits, abits */
-        32, 32, 32, 32,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_X8R8G8B8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 0,
-        /* Masks and shifts */
-        0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
-        16, 8, 0, 24
-        },
-	//-----------------------------------------------------------------------
-        {"PF_X8B8G8R8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 0,
-        /* Masks and shifts */
-        0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000,
-        0, 8, 16, 24
-        },
-	//-----------------------------------------------------------------------
-        {"PF_R8G8B8A8",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_HASALPHA | PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        8, 8, 8, 8,
-        /* Masks and shifts */
-        0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
-        24, 16, 8, 0
-        },
-	//-----------------------------------------------------------------------
-		{"PF_DEPTH",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_DEPTH,
-        /* Component type and count */
-        PCT_FLOAT32, 1, // ?
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-		0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-		{"PF_SHORT_RGBA",
-		/* Bytes per element */
-        8,
-        /* Flags */
-        PFF_HASALPHA,
-        /* Component type and count */
-        PCT_SHORT, 4,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 16, 16,
-        /* Masks and shifts */
-		0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_R3G3B2",
-        /* Bytes per element */
-        1,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        3, 3, 2, 0,
-        /* Masks and shifts */
-        0xE0, 0x1C, 0x03, 0,
-        5, 2, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT16_R",
-        /* Bytes per element */
-        2,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT16, 1,
-        /* rbits, gbits, bbits, abits */
-        16, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT32_R",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT32, 1,
-        /* rbits, gbits, bbits, abits */
-        32, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_SHORT_GR",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_NATIVEENDIAN,
-        /* Component type and count */
-        PCT_SHORT, 2,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 0, 0,
-        /* Masks and shifts */
-        0x0000FFFF, 0xFFFF0000, 0, 0, 
-		0, 16, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT16_GR",
-        /* Bytes per element */
-        4,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT16, 2,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-        {"PF_FLOAT32_GR",
-        /* Bytes per element */
-        8,
-        /* Flags */
-        PFF_FLOAT,
-        /* Component type and count */
-        PCT_FLOAT32, 2,
-        /* rbits, gbits, bbits, abits */
-        32, 32, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-	//-----------------------------------------------------------------------
-		{"PF_SHORT_RGB",
-		/* Bytes per element */
-        6,
-        /* Flags */
-        0,
-        /* Component type and count */
-        PCT_SHORT, 3,
-        /* rbits, gbits, bbits, abits */
-        16, 16, 16, 0,
-        /* Masks and shifts */
-		0, 0, 0, 0, 0, 0, 0, 0
-        },
-    //-----------------------------------------------------------------------
-		{"PF_PVRTC_RGB2",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-    //-----------------------------------------------------------------------
-		{"PF_PVRTC_RGBA2",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-    //-----------------------------------------------------------------------
-		{"PF_PVRTC_RGB4",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED,
-        /* Component type and count */
-        PCT_BYTE, 3,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-    //-----------------------------------------------------------------------
-		{"PF_PVRTC_RGBA4",
-        /* Bytes per element */
-        0,
-        /* Flags */
-        PFF_COMPRESSED | PFF_HASALPHA,
-        /* Component type and count */
-        PCT_BYTE, 4,
-        /* rbits, gbits, bbits, abits */
-        0, 0, 0, 0,
-        /* Masks and shifts */
-        0, 0, 0, 0, 0, 0, 0, 0
-        },
-        
-    };
-    //-----------------------------------------------------------------------
-	size_t PixelData::getConsecutiveSize() const
-	{
-		return PixelUtil::getMemorySize(getWidth(), getHeight(), getDepth(), format);
-	}
-	PixelData PixelData::getSubVolume(const Box &def) const
-	{
-		if(PixelUtil::isCompressed(format))
-		{
-			if(def.left == left && def.top == top && def.front == front &&
-			   def.right == right && def.bottom == bottom && def.back == back)
-			{
-				// Entire buffer is being queried
-				return *this;
-			}
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Cannot return subvolume of compressed PixelBuffer", "PixelBox::getSubVolume");
-		}
-		if(!contains(def))
-			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Bounds out of range", "PixelBox::getSubVolume");
-
-		const size_t elemSize = PixelUtil::getNumElemBytes(format);
-		// Calculate new data origin
-		// Notice how we do not propagate left/top/front from the incoming box, since
-		// the returned pointer is already offset
-		PixelData rval(def.getWidth(), def.getHeight(), def.getDepth(), format, 
-			((UINT8*)data) + ((def.left-left)*elemSize)
-			+ ((def.top-top)*rowPitch*elemSize)
-			+ ((def.front-front)*slicePitch*elemSize)
-		);
-
-		rval.rowPitch = rowPitch;
-		rval.slicePitch = slicePitch;
-		rval.format = format;
-
-		return rval;
-	}
-    //-----------------------------------------------------------------------
-    /**
-    * Directly get the description record for provided pixel format. For debug builds,
-    * this checks the bounds of fmt with an assertion.
-    */
-    static inline const PixelFormatDescription &getDescriptionFor(const PixelFormat fmt)
-    {
-        const int ord = (int)fmt;
-        assert(ord>=0 && ord<PF_COUNT);
-
-        return _pixelFormats[ord];
-    }
-    //-----------------------------------------------------------------------
-    size_t PixelUtil::getNumElemBytes( PixelFormat format )
-    {
-        return getDescriptionFor(format).elemBytes;
-    }
-	//-----------------------------------------------------------------------
-	size_t PixelUtil::getMemorySize(size_t width, size_t height, size_t depth, PixelFormat format)
-	{
-		if(isCompressed(format))
-		{
-			switch(format)
-			{
-				// DXT formats work by dividing the image into 4x4 blocks, then encoding each
-				// 4x4 block with a certain number of bytes. 
-				case PF_DXT1:
-					return ((width+3)/4)*((height+3)/4)*8 * depth;
-				case PF_DXT2:
-				case PF_DXT3:
-				case PF_DXT4:
-				case PF_DXT5:
-					return ((width+3)/4)*((height+3)/4)*16 * depth;
-
-                // Size calculations from the PVRTC OpenGL extension spec
-                // http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt
-                // Basically, 32 bytes is the minimum texture size.  Smaller textures are padded up to 32 bytes
-                case PF_PVRTC_RGB2:
-                case PF_PVRTC_RGBA2:
-					assert(depth == 1);
-                    return (std::max((int)width, 16) * std::max((int)height, 8) * 2 + 7) / 8;
-                case PF_PVRTC_RGB4:
-                case PF_PVRTC_RGBA4:
-					assert(depth == 1);
-                    return (std::max((int)width, 8) * std::max((int)height, 8) * 4 + 7) / 8;
-				default:
-				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid compressed pixel format",
-					"PixelUtil::getMemorySize");
-			}
-		}
-		else
-		{
-			return width*height*depth*getNumElemBytes(format);
-		}
-	}
-    //-----------------------------------------------------------------------
-    size_t PixelUtil::getNumElemBits( PixelFormat format )
-    {
-        return getDescriptionFor(format).elemBytes * 8;
-    }
-    //-----------------------------------------------------------------------
-    unsigned int PixelUtil::getFlags( PixelFormat format )
-    {
-        return getDescriptionFor(format).flags;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::hasAlpha(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_HASALPHA) > 0;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isFloatingPoint(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_FLOAT) > 0;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isCompressed(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_COMPRESSED) > 0;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isDepth(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_DEPTH) > 0;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isNativeEndian(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_NATIVEENDIAN) > 0;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isLuminance(PixelFormat format)
-    {
-        return (PixelUtil::getFlags(format) & PFF_LUMINANCE) > 0;
-    }
-    //-----------------------------------------------------------------------
-	bool PixelUtil::isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format)
-	{
-		if(isCompressed(format))
-		{
-			switch(format)
-			{
-				case PF_DXT1:
-				case PF_DXT2:
-				case PF_DXT3:
-				case PF_DXT4:
-				case PF_DXT5:
-					return ((width&3)==0 && (height&3)==0 && depth==1);
-				default:
-					return true;
-			}
-		}
-		else
-		{
-			return true;
-		}
-	}
-	//-----------------------------------------------------------------------
-    void PixelUtil::getBitDepths(PixelFormat format, int rgba[4])
-    {
-        const PixelFormatDescription &des = getDescriptionFor(format);
-        rgba[0] = des.rbits;
-        rgba[1] = des.gbits;
-        rgba[2] = des.bbits;
-        rgba[3] = des.abits;
-    }
-	//-----------------------------------------------------------------------
-	void PixelUtil::getBitMasks(PixelFormat format, UINT32 rgba[4])
-    {
-        const PixelFormatDescription &des = getDescriptionFor(format);
-        rgba[0] = des.rmask;
-        rgba[1] = des.gmask;
-        rgba[2] = des.bmask;
-        rgba[3] = des.amask;
-    }
-	//---------------------------------------------------------------------
-	void PixelUtil::getBitShifts(PixelFormat format, unsigned char rgba[4])
-	{
-		const PixelFormatDescription &des = getDescriptionFor(format);
-		rgba[0] = des.rshift;
-		rgba[1] = des.gshift;
-		rgba[2] = des.bshift;
-		rgba[3] = des.ashift;
-	}
-    //-----------------------------------------------------------------------
-    String PixelUtil::getFormatName(PixelFormat srcformat)
-    {
-        return getDescriptionFor(srcformat).name;
-    }
-    //-----------------------------------------------------------------------
-    bool PixelUtil::isAccessible(PixelFormat srcformat)
-    {
-        if (srcformat == PF_UNKNOWN)
-            return false;
-        unsigned int flags = getFlags(srcformat);
-        return !((flags & PFF_COMPRESSED) || (flags & PFF_DEPTH));
-    }
-    //-----------------------------------------------------------------------
-    PixelComponentType PixelUtil::getComponentType(PixelFormat fmt)
-    {
-        const PixelFormatDescription &des = getDescriptionFor(fmt);
-        return des.componentType;
-    }
-    //-----------------------------------------------------------------------
-    size_t PixelUtil::getComponentCount(PixelFormat fmt)
-    {
-        const PixelFormatDescription &des = getDescriptionFor(fmt);
-        return des.componentCount;
-    }
-    //-----------------------------------------------------------------------
-    PixelFormat PixelUtil::getFormatFromName(const String& name, bool accessibleOnly, bool caseSensitive)
-    {
-        String tmp = name;
-        if (!caseSensitive)
-        {
-            // We are stored upper-case format names.
-            StringUtil::toUpperCase(tmp);
-        }
-
-        for (int i = 0; i < PF_COUNT; ++i)
-        {
-            PixelFormat pf = static_cast<PixelFormat>(i);
-            if (!accessibleOnly || isAccessible(pf))
-            {
-                if (tmp == getFormatName(pf))
-                    return pf;
-            }
-        }
-        return PF_UNKNOWN;
-    }
-    //-----------------------------------------------------------------------
-    String PixelUtil::getBNFExpressionOfPixelFormats(bool accessibleOnly)
-    {
-        // Collect format names sorted by length, it's required by BNF compiler
-        // that similar tokens need longer ones comes first.
-        typedef multimap<String::size_type, String>::type FormatNameMap;
-        FormatNameMap formatNames;
-        for (size_t i = 0; i < PF_COUNT; ++i)
-        {
-            PixelFormat pf = static_cast<PixelFormat>(i);
-            if (!accessibleOnly || isAccessible(pf))
-            {
-                String formatName = getFormatName(pf);
-                formatNames.insert(std::make_pair(formatName.length(), formatName));
-            }
-        }
-
-        // Populate the BNF expression in reverse order
-        String result;
-        // Note: Stupid M$ VC7.1 can't dealing operator!= with FormatNameMap::const_reverse_iterator.
-        for (FormatNameMap::reverse_iterator j = formatNames.rbegin(); j != formatNames.rend(); ++j)
-        {
-            if (!result.empty())
-                result += " | ";
-            result += "'" + j->second + "'";
-        }
-
-        return result;
-    }
-    //-----------------------------------------------------------------------
-    PixelFormat PixelUtil::getFormatForBitDepths(PixelFormat fmt, UINT16 integerBits, UINT16 floatBits)
-    {
-        switch (integerBits)
-        {
-        case 16:
-            switch (fmt)
-            {
-            case PF_R8G8B8:
-            case PF_X8R8G8B8:
-                return PF_R5G6B5;
-
-            case PF_B8G8R8:
-            case PF_X8B8G8R8:
-                return PF_B5G6R5;
-
-            case PF_A8R8G8B8:
-            case PF_R8G8B8A8:
-            case PF_A8B8G8R8:
-            case PF_B8G8R8A8:
-                return PF_A4R4G4B4;
-
-            case PF_A2R10G10B10:
-            case PF_A2B10G10R10:
-                return PF_A1R5G5B5;
-
-            default:
-                // use original image format
-                break;
-            }
-            break;
-
-        case 32:
-            switch (fmt)
-            {
-            case PF_R5G6B5:
-                return PF_X8R8G8B8;
-
-            case PF_B5G6R5:
-                return PF_X8B8G8R8;
-
-            case PF_A4R4G4B4:
-                return PF_A8R8G8B8;
-
-            case PF_A1R5G5B5:
-                return PF_A2R10G10B10;
-
-            default:
-                // use original image format
-                break;
-            }
-            break;
-
-        default:
-            // use original image format
-            break;
-        }
-
-        switch (floatBits)
-        {
-        case 16:
-            switch (fmt)
-            {
-            case PF_FLOAT32_R:
-                return PF_FLOAT16_R;
-
-            case PF_FLOAT32_RGB:
-                return PF_FLOAT16_RGB;
-
-            case PF_FLOAT32_RGBA:
-                return PF_FLOAT16_RGBA;
-
-            default:
-                // use original image format
-                break;
-            }
-            break;
-
-        case 32:
-            switch (fmt)
-            {
-            case PF_FLOAT16_R:
-                return PF_FLOAT32_R;
-
-            case PF_FLOAT16_RGB:
-                return PF_FLOAT32_RGB;
-
-            case PF_FLOAT16_RGBA:
-                return PF_FLOAT32_RGBA;
-
-            default:
-                // use original image format
-                break;
-            }
-            break;
-
-        default:
-            // use original image format
-            break;
-        }
-
-        return fmt;
-    }
-    //-----------------------------------------------------------------------
-    /*************************************************************************
-    * Pixel packing/unpacking utilities
-    */
-    void PixelUtil::packColour(const Color &colour, const PixelFormat pf,  void* dest)
-    {
-        packColour(colour.r, colour.g, colour.b, colour.a, pf, dest);
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::packColour(const UINT8 r, const UINT8 g, const UINT8 b, const UINT8 a, const PixelFormat pf,  void* dest)
-    {
-        const PixelFormatDescription &des = getDescriptionFor(pf);
-        if(des.flags & PFF_NATIVEENDIAN) {
-            // Shortcut for integer formats packing
-            unsigned int value = ((Bitwise::fixedToFixed(r, 8, des.rbits)<<des.rshift) & des.rmask) |
-                ((Bitwise::fixedToFixed(g, 8, des.gbits)<<des.gshift) & des.gmask) |
-                ((Bitwise::fixedToFixed(b, 8, des.bbits)<<des.bshift) & des.bmask) |
-                ((Bitwise::fixedToFixed(a, 8, des.abits)<<des.ashift) & des.amask);
-            // And write to memory
-            Bitwise::intWrite(dest, des.elemBytes, value);
-        } else {
-            // Convert to float
-            packColour((float)r/255.0f,(float)g/255.0f,(float)b/255.0f,(float)a/255.0f, pf, dest);
-        }
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::packColour(const float r, const float g, const float b, const float a, const PixelFormat pf,  void* dest)
-    {
-        // Catch-it-all here
-        const PixelFormatDescription &des = getDescriptionFor(pf);
-        if(des.flags & PFF_NATIVEENDIAN) {
-            // Do the packing
-            //std::cerr << dest << " " << r << " " << g <<  " " << b << " " << a << std::endl;
-            const unsigned int value = ((Bitwise::floatToFixed(r, des.rbits)<<des.rshift) & des.rmask) |
-                ((Bitwise::floatToFixed(g, des.gbits)<<des.gshift) & des.gmask) |
-                ((Bitwise::floatToFixed(b, des.bbits)<<des.bshift) & des.bmask) |
-                ((Bitwise::floatToFixed(a, des.abits)<<des.ashift) & des.amask);
-            // And write to memory
-            Bitwise::intWrite(dest, des.elemBytes, value);
-        } else {
-            switch(pf)
-            {
-            case PF_FLOAT32_R:
-                ((float*)dest)[0] = r;
-                break;
-			case PF_FLOAT32_GR:
-				((float*)dest)[0] = g;
-				((float*)dest)[1] = r;
-				break;
-            case PF_FLOAT32_RGB:
-                ((float*)dest)[0] = r;
-                ((float*)dest)[1] = g;
-                ((float*)dest)[2] = b;
-                break;
-            case PF_FLOAT32_RGBA:
-                ((float*)dest)[0] = r;
-                ((float*)dest)[1] = g;
-                ((float*)dest)[2] = b;
-                ((float*)dest)[3] = a;
-                break;
-            case PF_FLOAT16_R:
-                ((UINT16*)dest)[0] = Bitwise::floatToHalf(r);
-                break;
-			case PF_FLOAT16_GR:
-				((UINT16*)dest)[0] = Bitwise::floatToHalf(g);
-				((UINT16*)dest)[1] = Bitwise::floatToHalf(r);
-				break;
-            case PF_FLOAT16_RGB:
-                ((UINT16*)dest)[0] = Bitwise::floatToHalf(r);
-                ((UINT16*)dest)[1] = Bitwise::floatToHalf(g);
-                ((UINT16*)dest)[2] = Bitwise::floatToHalf(b);
-                break;
-            case PF_FLOAT16_RGBA:
-                ((UINT16*)dest)[0] = Bitwise::floatToHalf(r);
-                ((UINT16*)dest)[1] = Bitwise::floatToHalf(g);
-                ((UINT16*)dest)[2] = Bitwise::floatToHalf(b);
-                ((UINT16*)dest)[3] = Bitwise::floatToHalf(a);
-                break;
-            case PF_SHORT_RGB:
-				((UINT16*)dest)[0] = (UINT16)Bitwise::floatToFixed(r, 16);
-                ((UINT16*)dest)[1] = (UINT16)Bitwise::floatToFixed(g, 16);
-                ((UINT16*)dest)[2] = (UINT16)Bitwise::floatToFixed(b, 16);
-                break;
-			case PF_SHORT_RGBA:
-				((UINT16*)dest)[0] = (UINT16)Bitwise::floatToFixed(r, 16);
-                ((UINT16*)dest)[1] = (UINT16)Bitwise::floatToFixed(g, 16);
-                ((UINT16*)dest)[2] = (UINT16)Bitwise::floatToFixed(b, 16);
-                ((UINT16*)dest)[3] = (UINT16)Bitwise::floatToFixed(a, 16);
-				break;
-			case PF_BYTE_LA:
-				((UINT8*)dest)[0] = (UINT8)Bitwise::floatToFixed(r, 8);
-                ((UINT8*)dest)[1] = (UINT8)Bitwise::floatToFixed(a, 8);
-				break;
-            default:
-                // Not yet supported
-                OGRE_EXCEPT(
-                    Exception::ERR_NOT_IMPLEMENTED,
-                    "pack to "+getFormatName(pf)+" not implemented",
-                    "PixelUtil::packColour");
-                break;
-            }
-        }
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::unpackColour(Color *colour, PixelFormat pf,  const void* src)
-    {
-        unpackColour(&colour->r, &colour->g, &colour->b, &colour->a, pf, src);
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::unpackColour(UINT8 *r, UINT8 *g, UINT8 *b, UINT8 *a, PixelFormat pf,  const void* src)
-    {
-        const PixelFormatDescription &des = getDescriptionFor(pf);
-        if(des.flags & PFF_NATIVEENDIAN) {
-            // Shortcut for integer formats unpacking
-            const unsigned int value = Bitwise::intRead(src, des.elemBytes);
-            if(des.flags & PFF_LUMINANCE)
-            {
-                // Luminance format -- only rbits used
-                *r = *g = *b = (UINT8)Bitwise::fixedToFixed(
-                    (value & des.rmask)>>des.rshift, des.rbits, 8);
-            }
-            else
-            {
-                *r = (UINT8)Bitwise::fixedToFixed((value & des.rmask)>>des.rshift, des.rbits, 8);
-                *g = (UINT8)Bitwise::fixedToFixed((value & des.gmask)>>des.gshift, des.gbits, 8);
-                *b = (UINT8)Bitwise::fixedToFixed((value & des.bmask)>>des.bshift, des.bbits, 8);
-            }
-            if(des.flags & PFF_HASALPHA)
-            {
-                *a = (UINT8)Bitwise::fixedToFixed((value & des.amask)>>des.ashift, des.abits, 8);
-            }
-            else
-            {
-                *a = 255; // No alpha, default a component to full
-            }
-        } else {
-            // Do the operation with the more generic floating point
-            float rr, gg, bb, aa;
-            unpackColour(&rr,&gg,&bb,&aa, pf, src);
-            *r = (UINT8)Bitwise::floatToFixed(rr, 8);
-            *g = (UINT8)Bitwise::floatToFixed(gg, 8);
-            *b = (UINT8)Bitwise::floatToFixed(bb, 8);
-            *a = (UINT8)Bitwise::floatToFixed(aa, 8);
-        }
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::unpackColour(float *r, float *g, float *b, float *a,
-        PixelFormat pf,  const void* src)
-    {
-        const PixelFormatDescription &des = getDescriptionFor(pf);
-        if(des.flags & PFF_NATIVEENDIAN) {
-            // Shortcut for integer formats unpacking
-            const unsigned int value = Bitwise::intRead(src, des.elemBytes);
-            if(des.flags & PFF_LUMINANCE)
-            {
-                // Luminance format -- only rbits used
-                *r = *g = *b = Bitwise::fixedToFloat(
-                    (value & des.rmask)>>des.rshift, des.rbits);
-            }
-            else
-            {
-                *r = Bitwise::fixedToFloat((value & des.rmask)>>des.rshift, des.rbits);
-                *g = Bitwise::fixedToFloat((value & des.gmask)>>des.gshift, des.gbits);
-                *b = Bitwise::fixedToFloat((value & des.bmask)>>des.bshift, des.bbits);
-            }
-            if(des.flags & PFF_HASALPHA)
-            {
-                *a = Bitwise::fixedToFloat((value & des.amask)>>des.ashift, des.abits);
-            }
-            else
-            {
-                *a = 1.0f; // No alpha, default a component to full
-            }
-        } else {
-            switch(pf)
-            {
-            case PF_FLOAT32_R:
-                *r = *g = *b = ((float*)src)[0];
-                *a = 1.0f;
-                break;
-			case PF_FLOAT32_GR:
-				*g = ((float*)src)[0];
-				*r = *b = ((float*)src)[1];
-				*a = 1.0f;
-				break;
-            case PF_FLOAT32_RGB:
-                *r = ((float*)src)[0];
-                *g = ((float*)src)[1];
-                *b = ((float*)src)[2];
-                *a = 1.0f;
-                break;
-            case PF_FLOAT32_RGBA:
-                *r = ((float*)src)[0];
-                *g = ((float*)src)[1];
-                *b = ((float*)src)[2];
-                *a = ((float*)src)[3];
-                break;
-            case PF_FLOAT16_R:
-                *r = *g = *b = Bitwise::halfToFloat(((UINT16*)src)[0]);
-                *a = 1.0f;
-                break;
-			case PF_FLOAT16_GR:
-				*g = Bitwise::halfToFloat(((UINT16*)src)[0]);
-				*r = *b = Bitwise::halfToFloat(((UINT16*)src)[1]);
-				*a = 1.0f;
-				break;
-            case PF_FLOAT16_RGB:
-                *r = Bitwise::halfToFloat(((UINT16*)src)[0]);
-                *g = Bitwise::halfToFloat(((UINT16*)src)[1]);
-                *b = Bitwise::halfToFloat(((UINT16*)src)[2]);
-                *a = 1.0f;
-                break;
-            case PF_FLOAT16_RGBA:
-                *r = Bitwise::halfToFloat(((UINT16*)src)[0]);
-                *g = Bitwise::halfToFloat(((UINT16*)src)[1]);
-                *b = Bitwise::halfToFloat(((UINT16*)src)[2]);
-                *a = Bitwise::halfToFloat(((UINT16*)src)[3]);
-                break;
-			case PF_SHORT_RGB:
-				*r = Bitwise::fixedToFloat(((UINT16*)src)[0], 16);
-                *g = Bitwise::fixedToFloat(((UINT16*)src)[1], 16);
-				*b = Bitwise::fixedToFloat(((UINT16*)src)[2], 16);
-				*a = 1.0f;
-				break;
-			case PF_SHORT_RGBA:
-				*r = Bitwise::fixedToFloat(((UINT16*)src)[0], 16);
-                *g = Bitwise::fixedToFloat(((UINT16*)src)[1], 16);
-				*b = Bitwise::fixedToFloat(((UINT16*)src)[2], 16);
-				*a = Bitwise::fixedToFloat(((UINT16*)src)[3], 16);
-				break;
-			case PF_BYTE_LA:
-				*r = *g = *b = Bitwise::fixedToFloat(((UINT8*)src)[0], 8);
-				*a = Bitwise::fixedToFloat(((UINT8*)src)[1], 8);
-				break;
-            default:
-                // Not yet supported
-                OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-                    "unpack from "+getFormatName(pf)+" not implemented",
-                    "PixelUtil::unpackColour");
-                break;
-            }
-        }
-    }
-    //-----------------------------------------------------------------------
-    /* Convert pixels from one format to another */
-    void PixelUtil::bulkPixelConversion(void *srcp, PixelFormat srcFormat,
-        void *destp, PixelFormat dstFormat, unsigned int count)
-    {
-        PixelData src(count, 1, 1, srcFormat, srcp),
-				 dst(count, 1, 1, dstFormat, destp);
-
-        bulkPixelConversion(src, dst);
-    }
-    //-----------------------------------------------------------------------
-    void PixelUtil::bulkPixelConversion(const PixelData &src, const PixelData &dst)
-    {
-        assert(src.getWidth() == dst.getWidth() &&
-			   src.getHeight() == dst.getHeight() &&
-			   src.getDepth() == dst.getDepth());
-
-		// Check for compressed formats, we don't support decompression, compression or recoding
-		if(PixelUtil::isCompressed(src.format) || PixelUtil::isCompressed(dst.format))
-		{
-			if(src.format == dst.format)
-			{
-				memcpy(dst.data, src.data, src.getConsecutiveSize());
-				return;
-			}
-			else
-			{
-				OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
-					"This method can not be used to compress or decompress images",
-					"PixelUtil::bulkPixelConversion");
-			}
-		}
-
-        // The easy case
-        if(src.format == dst.format) {
-            // Everything consecutive?
-            if(src.isConsecutive() && dst.isConsecutive())
-            {
-				memcpy(dst.data, src.data, src.getConsecutiveSize());
-                return;
-            }
-
-            const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
-            const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
-            UINT8 *srcptr = static_cast<UINT8*>(src.data)
-                + (src.left + src.top * src.rowPitch + src.front * src.slicePitch) * srcPixelSize;
-            UINT8 *dstptr = static_cast<UINT8*>(dst.data)
-				+ (dst.left + dst.top * dst.rowPitch + dst.front * dst.slicePitch) * dstPixelSize;
-
-            // Calculate pitches+skips in bytes
-            const size_t srcRowPitchBytes = src.rowPitch*srcPixelSize;
-            //const size_t srcRowSkipBytes = src.getRowSkip()*srcPixelSize;
-            const size_t srcSliceSkipBytes = src.getSliceSkip()*srcPixelSize;
-
-            const size_t dstRowPitchBytes = dst.rowPitch*dstPixelSize;
-            //const size_t dstRowSkipBytes = dst.getRowSkip()*dstPixelSize;
-            const size_t dstSliceSkipBytes = dst.getSliceSkip()*dstPixelSize;
-
-            // Otherwise, copy per row
-            const size_t rowSize = src.getWidth()*srcPixelSize;
-            for(size_t z=src.front; z<src.back; z++)
-            {
-                for(size_t y=src.top; y<src.bottom; y++)
-                {
-					memcpy(dstptr, srcptr, rowSize);
-                    srcptr += srcRowPitchBytes;
-                    dstptr += dstRowPitchBytes;
-                }
-                srcptr += srcSliceSkipBytes;
-                dstptr += dstSliceSkipBytes;
-            }
-            return;
-        }
-		// Converting to PF_X8R8G8B8 is exactly the same as converting to
-		// PF_A8R8G8B8. (same with PF_X8B8G8R8 and PF_A8B8G8R8)
-		if(dst.format == PF_X8R8G8B8 || dst.format == PF_X8B8G8R8)
-		{
-			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
-			// optimized conversions
-			PixelData tempdst = dst;
-			tempdst.format = dst.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
-			bulkPixelConversion(src, tempdst);
-			return;
-		}
-		// Converting from PF_X8R8G8B8 is exactly the same as converting from
-		// PF_A8R8G8B8, given that the destination format does not have alpha.
-		if((src.format == PF_X8R8G8B8||src.format == PF_X8B8G8R8) && !hasAlpha(dst.format))
-		{
-			// Do the same conversion, with PF_A8R8G8B8, which has a lot of
-			// optimized conversions
-			PixelData tempsrc = src;
-			tempsrc.format = src.format==PF_X8R8G8B8?PF_A8R8G8B8:PF_A8B8G8R8;
-			bulkPixelConversion(tempsrc, dst);
-			return;
-		}
-
-        const size_t srcPixelSize = PixelUtil::getNumElemBytes(src.format);
-        const size_t dstPixelSize = PixelUtil::getNumElemBytes(dst.format);
-        UINT8 *srcptr = static_cast<UINT8*>(src.data)
-            + (src.left + src.top * src.rowPitch + src.front * src.slicePitch) * srcPixelSize;
-        UINT8 *dstptr = static_cast<UINT8*>(dst.data)
-            + (dst.left + dst.top * dst.rowPitch + dst.front * dst.slicePitch) * dstPixelSize;
-		
-		// Old way, not taking into account box dimensions
-		//UINT8 *srcptr = static_cast<UINT8*>(src.data), *dstptr = static_cast<UINT8*>(dst.data);
-
-        // Calculate pitches+skips in bytes
-        const size_t srcRowSkipBytes = src.getRowSkip()*srcPixelSize;
-        const size_t srcSliceSkipBytes = src.getSliceSkip()*srcPixelSize;
-        const size_t dstRowSkipBytes = dst.getRowSkip()*dstPixelSize;
-        const size_t dstSliceSkipBytes = dst.getSliceSkip()*dstPixelSize;
-
-        // The brute force fallback
-        float r,g,b,a;
-        for(size_t z=src.front; z<src.back; z++)
-        {
-            for(size_t y=src.top; y<src.bottom; y++)
-            {
-                for(size_t x=src.left; x<src.right; x++)
-                {
-                    unpackColour(&r, &g, &b, &a, src.format, srcptr);
-                    packColour(r, g, b, a, dst.format, dstptr);
-                    srcptr += srcPixelSize;
-                    dstptr += dstPixelSize;
-                }
-                srcptr += srcRowSkipBytes;
-                dstptr += dstRowSkipBytes;
-            }
-            srcptr += srcSliceSkipBytes;
-            dstptr += dstSliceSkipBytes;
-        }
-    }
-
-	void PixelUtil::scale(const PixelData &src, const PixelData &scaled, Filter filter)
-	{
-		assert(PixelUtil::isAccessible(src.format));
-		assert(PixelUtil::isAccessible(scaled.format));
-
-		PixelData temp;
-		switch (filter) 
-		{
-		default:
-		case FILTER_NEAREST:
-			if(src.format == scaled.format) 
-			{
-				// No intermediate buffer needed
-				temp = scaled;
-			}
-			else
-			{
-				// Allocate temporary buffer of destination size in source format 
-				temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
-				temp.data = malloc(temp.getConsecutiveSize());
-			}
-			// super-optimized: no conversion
-			switch (PixelUtil::getNumElemBytes(src.format)) 
-			{
-			case 1: NearestResampler<1>::scale(src, temp); break;
-			case 2: NearestResampler<2>::scale(src, temp); break;
-			case 3: NearestResampler<3>::scale(src, temp); break;
-			case 4: NearestResampler<4>::scale(src, temp); break;
-			case 6: NearestResampler<6>::scale(src, temp); break;
-			case 8: NearestResampler<8>::scale(src, temp); break;
-			case 12: NearestResampler<12>::scale(src, temp); break;
-			case 16: NearestResampler<16>::scale(src, temp); break;
-			default:
-				// never reached
-				assert(false);
-			}
-			if(temp.data != scaled.data)
-			{
-				// Blit temp buffer
-				PixelUtil::bulkPixelConversion(temp, scaled);
-
-				free(temp.data);
-			}
-			break;
-
-		case FILTER_LINEAR:
-		case FILTER_BILINEAR:
-			switch (src.format) 
-			{
-			case PF_L8: case PF_A8: case PF_BYTE_LA:
-			case PF_R8G8B8: case PF_B8G8R8:
-			case PF_R8G8B8A8: case PF_B8G8R8A8:
-			case PF_A8B8G8R8: case PF_A8R8G8B8:
-			case PF_X8B8G8R8: case PF_X8R8G8B8:
-				if(src.format == scaled.format) 
-				{
-					// No intermediate buffer needed
-					temp = scaled;
-				}
-				else
-				{
-					// Allocate temp buffer of destination size in source format 
-					temp = PixelData(scaled.getWidth(), scaled.getHeight(), scaled.getDepth(), src.format);
-					temp.data = malloc(temp.getConsecutiveSize());
-				}
-				// super-optimized: byte-oriented math, no conversion
-				switch (PixelUtil::getNumElemBytes(src.format)) 
-				{
-				case 1: LinearResampler_Byte<1>::scale(src, temp); break;
-				case 2: LinearResampler_Byte<2>::scale(src, temp); break;
-				case 3: LinearResampler_Byte<3>::scale(src, temp); break;
-				case 4: LinearResampler_Byte<4>::scale(src, temp); break;
-				default:
-					// never reached
-					assert(false);
-				}
-				if(temp.data != scaled.data)
-				{
-					// Blit temp buffer
-					PixelUtil::bulkPixelConversion(temp, scaled);
-					free(temp.data);
-				}
-				break;
-			case PF_FLOAT32_RGB:
-			case PF_FLOAT32_RGBA:
-				if (scaled.format == PF_FLOAT32_RGB || scaled.format == PF_FLOAT32_RGBA)
-				{
-					// float32 to float32, avoid unpack/repack overhead
-					LinearResampler_Float32::scale(src, scaled);
-					break;
-				}
-				// else, fall through
-			default:
-				// non-optimized: floating-point math, performs conversion but always works
-				LinearResampler::scale(src, scaled);
-			}
-			break;
-		}
-	}
-
-    Color PixelData::getColourAt(size_t x, size_t y, size_t z)
-    {
-        Color cv;
-
-        unsigned char pixelSize = PixelUtil::getNumElemBytes(format);
-        size_t pixelOffset = pixelSize * (z * slicePitch + y * rowPitch + x);
-        PixelUtil::unpackColour(&cv, format, (unsigned char *)data + pixelOffset);
-
-        return cv;
-    }
-
-    void PixelData::setColourAt(Color const &cv, size_t x, size_t y, size_t z)
-    {
-        unsigned char pixelSize = PixelUtil::getNumElemBytes(format);
-        size_t pixelOffset = pixelSize * (z * slicePitch + y * rowPitch + x);
-        PixelUtil::packColour(cv, format, (unsigned char *)data + pixelOffset);
-    }
-
-}

+ 0 - 528
CamelotRenderer/CmPixelUtil.h

@@ -1,528 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef _PixelFormat_H__
-#define _PixelFormat_H__
-
-#include "CmPrerequisites.h"
-#include "CmCommon.h"
-
-namespace CamelotEngine {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup Image
-	*  @{
-	*/
-	/** The pixel format used for images, textures, and render surfaces */
-    enum PixelFormat
-    {
-        /// Unknown pixel format.
-        PF_UNKNOWN = 0,
-        /// 8-bit pixel format, all bits luminace.
-        PF_L8 = 1,
-		PF_BYTE_L = PF_L8,
-        /// 16-bit pixel format, all bits luminace.
-        PF_L16 = 2,
-		PF_SHORT_L = PF_L16,
-        /// 8-bit pixel format, all bits alpha.
-        PF_A8 = 3,
-		PF_BYTE_A = PF_A8,
-        /// 8-bit pixel format, 4 bits alpha, 4 bits luminance.
-        PF_A4L4 = 4,
-		/// 2 byte pixel format, 1 byte luminance, 1 byte alpha
-		PF_BYTE_LA = 5,
-        /// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue.
-        PF_R5G6B5 = 6,
-		/// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue.
-        PF_B5G6R5 = 7,
-        /// 8-bit pixel format, 2 bits blue, 3 bits green, 3 bits red.
-        PF_R3G3B2 = 31,
-        /// 16-bit pixel format, 4 bits for alpha, red, green and blue.
-        PF_A4R4G4B4 = 8,
-        /// 16-bit pixel format, 5 bits for blue, green, red and 1 for alpha.
-        PF_A1R5G5B5 = 9,
-        /// 24-bit pixel format, 8 bits for red, green and blue.
-        PF_R8G8B8 = 10,
-        /// 24-bit pixel format, 8 bits for blue, green and red.
-        PF_B8G8R8 = 11,
-        /// 32-bit pixel format, 8 bits for alpha, red, green and blue.
-        PF_A8R8G8B8 = 12,
-        /// 32-bit pixel format, 8 bits for blue, green, red and alpha.
-        PF_A8B8G8R8 = 13,
-        /// 32-bit pixel format, 8 bits for blue, green, red and alpha.
-        PF_B8G8R8A8 = 14,
-		/// 32-bit pixel format, 8 bits for red, green, blue and alpha.
-		PF_R8G8B8A8 = 28,
-        /// 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue
-        /// like PF_A8R8G8B8, but alpha will get discarded
-        PF_X8R8G8B8 = 26,
-        /// 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red
-        /// like PF_A8B8G8R8, but alpha will get discarded
-        PF_X8B8G8R8 = 27,
-#if CM_ENDIAN == CM_ENDIAN_BIG
-		/// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue
-		PF_BYTE_RGB = PF_R8G8B8,
-		/// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red
-		PF_BYTE_BGR = PF_B8G8R8,
-		/// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha
-		PF_BYTE_BGRA = PF_B8G8R8A8,
-		/// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha
-		PF_BYTE_RGBA = PF_R8G8B8A8,
-#else
-		/// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue
-		PF_BYTE_RGB = PF_B8G8R8,
-		/// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red
-		PF_BYTE_BGR = PF_R8G8B8,
-		/// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha
-		PF_BYTE_BGRA = PF_A8R8G8B8,
-		/// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha
-		PF_BYTE_RGBA = PF_A8B8G8R8,
-#endif        
-        /// 32-bit pixel format, 2 bits for alpha, 10 bits for red, green and blue.
-        PF_A2R10G10B10 = 15,
-        /// 32-bit pixel format, 10 bits for blue, green and red, 2 bits for alpha.
-        PF_A2B10G10R10 = 16,
-        /// DDS (DirectDraw Surface) DXT1 format
-        PF_DXT1 = 17,
-        /// DDS (DirectDraw Surface) DXT2 format
-        PF_DXT2 = 18,
-        /// DDS (DirectDraw Surface) DXT3 format
-        PF_DXT3 = 19,
-        /// DDS (DirectDraw Surface) DXT4 format
-        PF_DXT4 = 20,
-        /// DDS (DirectDraw Surface) DXT5 format
-        PF_DXT5 = 21,
-		// 16-bit pixel format, 16 bits (float) for red
-        PF_FLOAT16_R = 32,
-        // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue
-        PF_FLOAT16_RGB = 22,
-        // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha
-        PF_FLOAT16_RGBA = 23,
-		// 32-bit pixel format, 32 bits (float) for red
-        PF_FLOAT32_R = 33,
-        // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue
-        PF_FLOAT32_RGB = 24,
-        // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha
-        PF_FLOAT32_RGBA = 25,
-		// 32-bit, 2-channel s10e5 floating point pixel format, 16-bit green, 16-bit red
-		PF_FLOAT16_GR = 35,
-		// 64-bit, 2-channel floating point pixel format, 32-bit green, 32-bit red
-		PF_FLOAT32_GR = 36,
-		// Depth texture format
-		PF_DEPTH = 29,
-		// 64-bit pixel format, 16 bits for red, green, blue and alpha
-		PF_SHORT_RGBA = 30,
-		// 32-bit pixel format, 16-bit green, 16-bit red
-		PF_SHORT_GR = 34,
-		// 48-bit pixel format, 16 bits for red, green and blue
-		PF_SHORT_RGB = 37,
-        /// PVRTC (PowerVR) RGB 2 bpp
-        PF_PVRTC_RGB2 = 38,
-        /// PVRTC (PowerVR) RGBA 2 bpp
-        PF_PVRTC_RGBA2 = 39,
-        /// PVRTC (PowerVR) RGB 4 bpp
-        PF_PVRTC_RGB4 = 40,
-        /// PVRTC (PowerVR) RGBA 4 bpp
-        PF_PVRTC_RGBA4 = 41,
-		// Number of pixel formats currently defined
-        PF_COUNT = 42
-    };
-	typedef vector<PixelFormat>::type PixelFormatList;
-
-    /**
-     * Flags defining some on/off properties of pixel formats
-     */
-    enum PixelFormatFlags {
-        // This format has an alpha channel
-        PFF_HASALPHA        = 0x00000001,      
-        // This format is compressed. This invalidates the values in elemBytes,
-        // elemBits and the bit counts as these might not be fixed in a compressed format.
-        PFF_COMPRESSED    = 0x00000002,
-        // This is a floating point format
-        PFF_FLOAT           = 0x00000004,         
-        // This is a depth format (for depth textures)
-        PFF_DEPTH           = 0x00000008,
-        // Format is in native endian. Generally true for the 16, 24 and 32 bits
-        // formats which can be represented as machine integers.
-        PFF_NATIVEENDIAN    = 0x00000010,
-        // This is an intensity format instead of a RGB one. The luminance
-        // replaces R,G and B. (but not A)
-        PFF_LUMINANCE       = 0x00000020
-    };
-    
-    /** Pixel component format */
-    enum PixelComponentType
-    {
-        PCT_BYTE = 0,    /// Byte per component (8 bit fixed 0.0..1.0)
-        PCT_SHORT = 1,   /// Short per component (16 bit fixed 0.0..1.0))
-        PCT_FLOAT16 = 2, /// 16 bit float per component
-        PCT_FLOAT32 = 3, /// 32 bit float per component
-        PCT_COUNT = 4    /// Number of pixel types
-    };
-    
-	/** A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
-     	In case of a rectangle, depth must be 1. 
-     	Pixels are stored as a succession of "depth" slices, each containing "height" rows of 
-     	"width" pixels.
-    */
-    class CM_EXPORT PixelData: public Box {
-    public:
-    	/// Parameter constructor for setting the members manually
-    	PixelData() {}
-		~PixelData() {}
-		/** Constructor providing extents in the form of a Box object. This constructor
-    		assumes the pixel data is laid out consecutively in memory. (this
-    		means row after row, slice after slice, with no space in between)
-    		@param extents	    Extents of the region defined by data
-    		@param pixelFormat	Format of this buffer
-    		@param pixelData	Pointer to the actual data
-    	*/
-		PixelData(const Box &extents, PixelFormat pixelFormat, void *pixelData=0):
-			Box(extents), data(pixelData), format(pixelFormat)
-		{
-			setConsecutive();
-		}
-    	/** Constructor providing width, height and depth. This constructor
-    		assumes the pixel data is laid out consecutively in memory. (this
-    		means row after row, slice after slice, with no space in between)
-    		@param width	    Width of the region
-    		@param height	    Height of the region
-    		@param depth	    Depth of the region
-    		@param pixelFormat	Format of this buffer
-    		@param pixelData    Pointer to the actual data
-    	*/
-    	PixelData(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0):
-    		Box(0, 0, 0, width, height, depth),
-    		data(pixelData), format(pixelFormat)
-    	{
-    		setConsecutive();
-    	}
-    	
-        /// The data pointer 
-        void *data;
-        /// The pixel format 
-        PixelFormat format;
-        /** Number of elements between the leftmost pixel of one row and the left
-         	pixel of the next. This value must always be equal to getWidth() (consecutive) 
-			for compressed formats.
-        */
-        size_t rowPitch;
-        /** Number of elements between the top left pixel of one (depth) slice and 
-         	the top left pixel of the next. This can be a negative value. Must be a multiple of
-         	rowPitch. This value must always be equal to getWidth()*getHeight() (consecutive) 
-			for compressed formats.
-        */
-        size_t slicePitch;
-        
-        /** Set the rowPitch and slicePitch so that the buffer is laid out consecutive 
-         	in memory.
-        */        
-        void setConsecutive()
-        {
-            rowPitch = getWidth();
-            slicePitch = getWidth()*getHeight();
-        }
-        /**	Get the number of elements between one past the rightmost pixel of 
-         	one row and the leftmost pixel of the next row. (IE this is zero if rows
-         	are consecutive).
-        */
-        size_t getRowSkip() const { return rowPitch - getWidth(); }
-        /** Get the number of elements between one past the right bottom pixel of
-         	one slice and the left top pixel of the next slice. (IE this is zero if slices
-         	are consecutive).
-        */
-        size_t getSliceSkip() const { return slicePitch - (getHeight() * rowPitch); }
-
-        /** Return whether this buffer is laid out consecutive in memory (ie the pitches
-         	are equal to the dimensions)
-        */        
-        bool isConsecutive() const 
-		{ 
-			return rowPitch == getWidth() && slicePitch == getWidth()*getHeight(); 
-		}
-        /** Return the size (in bytes) this image would take if it was
-        	laid out consecutive in memory
-      	*/
-      	size_t getConsecutiveSize() const;
-      	/** Return a subvolume of this PixelBox.
-      		@param def	Defines the bounds of the subregion to return
-      		@returns	A pixel box describing the region and the data in it
-      		@remarks	This function does not copy any data, it just returns
-      			a PixelBox object with a data pointer pointing somewhere inside 
-      			the data of object.
-      		@throws	Exception(ERR_INVALIDPARAMS) if def is not fully contained
-      	*/
-      	PixelData getSubVolume(const Box &def) const;
-        
-        /**
-         * Get colour value from a certain location in the PixelBox. The z coordinate
-         * is only valid for cubemaps and volume textures. This uses the first (largest)
-         * mipmap.
-         */
-        Color getColourAt(size_t x, size_t y, size_t z);
-
-        /**
-         * Set colour value at a certain location in the PixelBox. The z coordinate
-         * is only valid for cubemaps and volume textures. This uses the first (largest)
-         * mipmap.
-         */
-        void setColourAt(Color const &cv, size_t x, size_t y, size_t z);
-    };
-    
-
-    /**
-     * Some utility functions for packing and unpacking pixel data
-     */
-    class CM_EXPORT PixelUtil {
-    public:
-        /** Returns the size in bytes of an element of the given pixel format.
-         @returns
-               The size in bytes of an element. See Remarks.
-         @remarks
-               Passing PF_UNKNOWN will result in returning a size of 0 bytes.
-        */
-        static size_t getNumElemBytes( PixelFormat format );
-
-        /** Returns the size in bits of an element of the given pixel format.
-          @returns
-               The size in bits of an element. See Remarks.
-           @remarks
-               Passing PF_UNKNOWN will result in returning a size of 0 bits.
-        */
-        static size_t getNumElemBits( PixelFormat format );
-
-		/** Returns the size in memory of a region with the given extents and pixel
-			format with consecutive memory layout.
-			@param width
-				The width of the area
-			@param height
-				The height of the area
-			@param depth
-				The depth of the area
-			@param format
-				The format of the area
-		  	@returns
-		  		The size in bytes
-			@remarks
-				In case that the format is non-compressed, this simply returns
-				width*height*depth*PixelUtil::getNumElemBytes(format). In the compressed
-				case, this does serious magic.
-		*/
-		static size_t getMemorySize(size_t width, size_t height, size_t depth, PixelFormat format);
-		
-        /** Returns the property flags for this pixel format
-          @returns
-               A bitfield combination of PFF_HASALPHA, PFF_ISCOMPRESSED,
-               PFF_FLOAT, PFF_DEPTH, PFF_NATIVEENDIAN, PFF_LUMINANCE
-          @remarks
-               This replaces the seperate functions for formatHasAlpha, formatIsFloat, ...
-        */
-        static unsigned int getFlags( PixelFormat format );
-
-        /** Shortcut method to determine if the format has an alpha component */
-        static bool hasAlpha(PixelFormat format);
-        /** Shortcut method to determine if the format is floating point */
-        static bool isFloatingPoint(PixelFormat format);
-        /** Shortcut method to determine if the format is compressed */
-        static bool isCompressed(PixelFormat format);
-        /** Shortcut method to determine if the format is a depth format. */
-        static bool isDepth(PixelFormat format);
-        /** Shortcut method to determine if the format is in native endian format. */
-        static bool isNativeEndian(PixelFormat format);
-        /** Shortcut method to determine if the format is a luminance format. */
-        static bool isLuminance(PixelFormat format);
-		
-		/** Return wether a certain image extent is valid for this image format.
-			@param width
-				The width of the area
-			@param height
-				The height of the area
-			@param depth
-				The depth of the area
-			@param format
-				The format of the area
-			@remarks For non-compressed formats, this is always true. For DXT formats,
-			only sizes with a width and height multiple of 4 and depth 1 are allowed.
-		*/
-		static bool isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format);
-
-        /** Gives the number of bits (RGBA) for a format. See remarks.          
-          @remarks      For non-colour formats (dxt, depth) this returns [0,0,0,0].
-        */
-        static void getBitDepths(PixelFormat format, int rgba[4]);
-
-		/** Gives the masks for the R, G, B and A component
-		  @note			Only valid for native endian formats
-        */
-        static void getBitMasks(PixelFormat format, UINT32 rgba[4]);
-
-		/** Gives the bit shifts for R, G, B and A component
-		@note			Only valid for native endian formats
-		*/
-		static void getBitShifts(PixelFormat format, unsigned char rgba[4]);
-
-        /** Gets the name of an image format
-        */
-        static String getFormatName(PixelFormat srcformat);
-
-        /** Returns wether the format can be packed or unpacked with the packColour()
-        and unpackColour() functions. This is generally not true for compressed and
-        depth formats as they are special. It can only be true for formats with a
-        fixed element size.
-          @returns 
-               true if yes, otherwise false
-        */
-        static bool isAccessible(PixelFormat srcformat);
-        
-        /** Returns the component type for a certain pixel format. Returns PCT_BYTE
-            in case there is no clear component type like with compressed formats.
-            This is one of PCT_BYTE, PCT_SHORT, PCT_FLOAT16, PCT_FLOAT32.
-        */
-        static PixelComponentType getComponentType(PixelFormat fmt);
-        
-        /** Returns the component count for a certain pixel format. Returns 3(no alpha) or 
-            4 (has alpha) in case there is no clear component type like with compressed formats.
-         */
-        static size_t getComponentCount(PixelFormat fmt);
-
-        /** Gets the format from given name.
-            @param  name            The string of format name
-            @param  accessibleOnly  If true, non-accessible format will treat as invalid format,
-                                    otherwise, all supported format are valid.
-            @param  caseSensitive   Should be set true if string match should use case sensitivity.
-            @returns                The format match the format name, or PF_UNKNOWN if is invalid name.
-        */
-        static PixelFormat getFormatFromName(const String& name, bool accessibleOnly = false, bool caseSensitive = false);
-
-        /** Gets the BNF expression of the pixel-formats.
-            @note                   The string returned by this function is intented to use as a BNF expression
-                                    to work with Compiler2Pass.
-            @param  accessibleOnly  If true, only accessible pixel format will take into account, otherwise all
-                                    pixel formats list in PixelFormat enumeration will being returned.
-            @returns                A string contains the BNF expression.
-        */
-        static String getBNFExpressionOfPixelFormats(bool accessibleOnly = false);
-
-        /** Returns the similar format but acoording with given bit depths.
-            @param fmt      The original foamt.
-            @param integerBits Preferred bit depth (pixel bits) for integer pixel format.
-                            Available values: 0, 16 and 32, where 0 (the default) means as it is.
-            @param floatBits Preferred bit depth (channel bits) for float pixel format.
-                            Available values: 0, 16 and 32, where 0 (the default) means as it is.
-            @returns        The format that similar original format with bit depth according
-                            with preferred bit depth, or original format if no convertion occuring.
-        */
-        static PixelFormat getFormatForBitDepths(PixelFormat fmt, UINT16 integerBits, UINT16 floatBits);
-
-        /** Pack a colour value to memory
-        	@param colour	The colour
-        	@param pf		Pixelformat in which to write the colour
-        	@param dest		Destination memory location
-        */
-        static void packColour(const Color &colour, const PixelFormat pf,  void* dest);
-        /** Pack a colour value to memory
-        	@param r,g,b,a	The four colour components, range 0x00 to 0xFF
-        	@param pf		Pixelformat in which to write the colour
-        	@param dest		Destination memory location
-        */
-        static void packColour(const UINT8 r, const UINT8 g, const UINT8 b, const UINT8 a, const PixelFormat pf,  void* dest);
-         /** Pack a colour value to memory
-        	@param r,g,b,a	The four colour components, range 0.0f to 1.0f
-        					(an exception to this case exists for floating point pixel
-        					formats, which don't clamp to 0.0f..1.0f)
-        	@param pf		Pixelformat in which to write the colour
-        	@param dest		Destination memory location
-        */
-        static void packColour(const float r, const float g, const float b, const float a, const PixelFormat pf,  void* dest);
-
-        /** Unpack a colour value from memory
-        	@param colour	The colour is returned here
-        	@param pf		Pixelformat in which to read the colour
-        	@param src		Source memory location
-        */
-        static void unpackColour(Color *colour, PixelFormat pf,  const void* src);
-        /** Unpack a colour value from memory
-        	@param r,g,b,a	The colour is returned here (as byte)
-        	@param pf		Pixelformat in which to read the colour
-        	@param src		Source memory location
-        	@remarks 	This function returns the colour components in 8 bit precision,
-        		this will lose precision when coming from PF_A2R10G10B10 or floating
-        		point formats.  
-        */
-        static void unpackColour(UINT8 *r, UINT8 *g, UINT8 *b, UINT8 *a, PixelFormat pf,  const void* src);
-        /** Unpack a colour value from memory
-        	@param r,g,b,a	The colour is returned here (as float)
-        	@param pf		Pixelformat in which to read the colour
-        	@param src		Source memory location
-        */
-        static void unpackColour(float *r, float *g, float *b, float *a, PixelFormat pf,  const void* src); 
-        
-        /** Convert consecutive pixels from one format to another. No dithering or filtering is being done. 
-         	Converting from RGB to luminance takes the R channel.  In case the source and destination format match,
-         	just a copy is done.
-         	@param	src			Pointer to source region
-         	@param	srcFormat	Pixel format of source region
-         	@param   dst			Pointer to destination region
-         	@param	dstFormat	Pixel format of destination region
-         */
-        static void bulkPixelConversion(void *src, PixelFormat srcFormat, void *dest, PixelFormat dstFormat, unsigned int count);
-
-      	/** Convert pixels from one format to another. No dithering or filtering is being done. Converting
-          	from RGB to luminance takes the R channel. 
-		 	@param	src			PixelBox containing the source pixels, pitches and format
-		 	@param	dst			PixelBox containing the destination pixels, pitches and format
-		 	@remarks The source and destination boxes must have the same
-         	dimensions. In case the source and destination format match, a plain copy is done.
-        */
-        static void bulkPixelConversion(const PixelData &src, const PixelData &dst);
-
-		enum Filter
-		{
-			FILTER_NEAREST,
-			FILTER_LINEAR,
-			FILTER_BILINEAR,
-			FILTER_BOX,
-			FILTER_TRIANGLE,
-			FILTER_BICUBIC
-		};
-
-		/** Scale a 1D, 2D or 3D image volume. 
-			@param 	src			PixelBox containing the source pointer, dimensions and format
-			@param 	dst			PixelBox containing the destination pointer, dimensions and format
-			@param 	filter		Which filter to use
-			@remarks 	This function can do pixel format conversion in the process.
-			@note	dst and src can point to the same PixelBox object without any problem
-		*/
-		static void scale(const PixelData &src, const PixelData &dst, Filter filter = FILTER_BILINEAR);
-    };
-	/** @} */
-	/** @} */
-
-}
-
-#endif