00001
00002
00012
00013
00014
00015
00016
00017 #ifndef __SIILUTIL_H__
00018 #define __SIILUTIL_H__
00019
00020
00021
00022
00023 #include <SIBCUtil.h>
00024
00025
00026
00027
00028
00029 #ifdef _WIN32
00030
00031 #ifndef LITTLE_ENDIAN
00032 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00033 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00034 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00035 #define INV_SWAP_SHORT(n) (n)
00036 #define INV_SWAP_LONG(n) (n)
00037 #define INV_SWAP_FLOAT(n) (n)
00038 #else
00039 #define SWAP_SHORT(n) (n)
00040 #define SWAP_LONG(n) (n)
00041 #define SWAP_FLOAT(n) (n)
00042 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00043 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00044 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00045 #endif
00046
00047 #else
00048
00049 #ifndef BYTE_ORDER
00050
00051 #ifndef LITTLE_ENDIAN
00052 #define SWAP_SHORT(n) (n)
00053 #define SWAP_LONG(n) (n)
00054 #define SWAP_FLOAT(n) (n)
00055 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00056 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00057 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00058 #else
00059 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00060 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00061 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00062 #define INV_SWAP_SHORT(n) (n)
00063 #define INV_SWAP_LONG(n) (n)
00064 #define INV_SWAP_FLOAT(n) (n)
00065 #endif
00066
00067 #else
00068
00069 #if ( BYTE_ORDER == LITTLE_ENDIAN )
00070 #define SWAP_SHORT(n) (n)
00071 #define SWAP_LONG(n) (n)
00072 #define SWAP_FLOAT(n) (n)
00073 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00074 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00075 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00076 #else
00077 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00078 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00079 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00080 #define INV_SWAP_SHORT(n) (n)
00081 #define INV_SWAP_LONG(n) (n)
00082 #define INV_SWAP_FLOAT(n) (n)
00083 #endif
00084
00085 #endif
00086
00087 #endif
00088
00089
00090
00091
00092
00097 extern SI_Float SI_ImageSwapFloat(SI_Float value);
00098
00099
00100 #endif // __SIILUTIL_H__