SIILUtil.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Crosswalk team
00004 //
00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.  
00006 // Use of this software is subject to the terms of the Autodesk license agreement 
00007 // provided at the time of installation or download, or which otherwise accompanies 
00008 // this software in either electronic or hard copy form.
00009 //
00010 //***************************************************************************************
00011 
00012 //***************************************************************************************
00013 // Defines
00014 //***************************************************************************************
00015 #ifndef __SIILUTIL_H__
00016 #define __SIILUTIL_H__
00017 
00018 //***************************************************************************************
00019 // Includes
00020 //***************************************************************************************
00021 #include <SIBCUtil.h>
00022 
00023 
00024 //***************************************************************************************
00025 // Defines
00026 //***************************************************************************************
00027 #ifdef _WIN32
00028 
00029 #ifndef LITTLE_ENDIAN
00030 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00031 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00032 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00033 #define INV_SWAP_SHORT(n) (n)
00034 #define INV_SWAP_LONG(n) (n)
00035 #define INV_SWAP_FLOAT(n) (n)
00036 #else
00037 #define SWAP_SHORT(n) (n)
00038 #define SWAP_LONG(n) (n)
00039 #define SWAP_FLOAT(n) (n)
00040 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00041 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00042 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00043 #endif
00044 
00045 #else
00046 
00047 #ifndef BYTE_ORDER
00048 
00049 #ifndef LITTLE_ENDIAN
00050 #define SWAP_SHORT(n) (n)
00051 #define SWAP_LONG(n) (n)
00052 #define SWAP_FLOAT(n) (n)
00053 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00054 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00055 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00056 #else
00057 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00058 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00059 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00060 #define INV_SWAP_SHORT(n) (n)
00061 #define INV_SWAP_LONG(n) (n)
00062 #define INV_SWAP_FLOAT(n) (n)
00063 #endif
00064 
00065 #else
00066 
00067 #if ( BYTE_ORDER == LITTLE_ENDIAN )
00068 #define SWAP_SHORT(n) (n)
00069 #define SWAP_LONG(n) (n)
00070 #define SWAP_FLOAT(n) (n)
00071 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00072 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00073 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00074 #else
00075 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00076 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00077 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00078 #define INV_SWAP_SHORT(n) (n)
00079 #define INV_SWAP_LONG(n) (n)
00080 #define INV_SWAP_FLOAT(n) (n)
00081 #endif
00082 
00083 #endif
00084 
00085 #endif
00086 
00087 
00088 //***************************************************************************************
00089 // Global Function
00090 //***************************************************************************************
00095 extern SI_Float SI_ImageSwapFloat(SI_Float value);
00096 
00097 
00098 #endif // __SIILUTIL_H__