|
A Portable Floating-Point-Based Image Format
1.0
|
00001 /* 00002 * Interface of the PFI library, a portable format to store 00003 * images with a double representation for every pixel of the same 00004 * color... 00005 * 00006 * Compatibility: ANSI 00007 * 00008 * $Date$ 00009 * $Revision$ 00010 * 00011 */ 00012 00013 #ifndef PFI_H__ 00014 #define PFI_H__ 00015 00016 #ifdef __cplusplus 00017 extern "C" { 00018 #endif /* __cplusplus */ 00019 00020 #include <stdio.h> 00021 #if defined (__GNUC__) && !defined (__USE_GNU) 00022 #define __USE_GNU 00023 #endif 00024 #include <limits.h> 00025 00026 #define PFI_VERSION "1.2" 00027 00028 #define PFI_EPSILON (3 * DBL_EPSILON) 00029 00030 /* 00031 * Have this thing ignored on non-Windows platforms: 00032 */ 00033 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined __WATCOMC__ 00034 # define DLL_EXPORT __declspec(dllexport) 00035 #else 00036 # define DLL_EXPORT 00037 #endif 00038 00039 #if defined (__GNUC__) && defined (__i386__) && (__GNUC__ >= 2) 00040 00041 typedef unsigned short pfiu16; 00042 typedef unsigned long pfiu32; 00043 #define PFIU16_MAX USHRT_MAX 00044 #define PFIU32_MAX ULONG_MAX 00045 00046 #define PFI_BYTE_SWAP 1 00047 00048 #elif defined (__WATCOMC__) 00049 00050 typedef unsigned short pfiu16; 00051 typedef unsigned long pfiu32; 00052 #define PFIU16_MAX USHRT_MAX 00053 #define PFIU32_MAX ULONG_MAX 00054 00055 #define PFI_BYTE_SWAP 1 00056 00057 #elif defined (__INTEL_COMPILER) && (__INTEL_COMPILER >= 60) 00058 00059 typedef unsigned short pfiu16; 00060 typedef unsigned long pfiu32; 00061 #define PFIU16_MAX USHRT_MAX 00062 #define PFIU32_MAX ULONG_MAX 00063 00064 #define PFI_BYTE_SWAP 1 00065 00066 #elif defined (__GNUC__) && defined (__sparc__) && (__GNUC__ >= 2) \ 00067 && !(defined (__sparcv9) || defined (__sparc_v9__)) 00068 00069 typedef unsigned short pfiu16; 00070 typedef unsigned long pfiu32; 00071 #define PFIU16_MAX USHRT_MAX 00072 #define PFIU32_MAX ULONG_MAX 00073 00074 #define PFI_BYTE_SWAP 0 00075 00076 #elif defined (__sgi) && defined (__host_mips) && defined (_MIPSEB) \ 00077 && defined (_MIPS_SZLONG) && _MIPS_SZLONG == 32 00078 00079 typedef unsigned short pfiu16; 00080 typedef unsigned long pfiu32; 00081 #define PFIU16_MAX USHRT_MAX 00082 #define PFIU32_MAX ULONG_MAX 00083 00084 #define PFI_BYTE_SWAP 0 00085 00086 #elif defined (__LCLINT__) 00087 00088 typedef unsigned short pfiu16; 00089 typedef unsigned long pfiu32; 00090 #define PFIU16_MAX USHRT_MAX 00091 #define PFIU32_MAX ULONG_MAX 00092 00093 #elif defined (_MSC_VER) 00094 #ifdef DPRINTF 00095 #undef DPRINTF 00096 #endif 00097 #define snprintf _snprintf 00098 typedef unsigned short pfiu16; 00099 typedef unsigned long pfiu32; 00100 #define PFIU16_MAX USHRT_MAX 00101 #define PFIU32_MAX ULONG_MAX 00102 00103 #define PFI_BYTE_SWAP 1 00104 00105 #else 00106 #error "I don't know your system, configure me!" 00107 #endif 00108 00109 #if PFI_BYTE_SWAP 00110 00111 #define PFI_BSWAP16(x) ((pfiu16) ( \ 00112 (((pfiu16)(x) & (pfiu16) 0x00ffU) << 8) | \ 00113 (((pfiu16)(x) & (pfiu16) 0xff00U) >> 8) )) 00114 00115 #define PFI_BSWAP32(x) ((pfiu32)( \ 00116 (((pfiu32)(x) & (pfiu32)0x000000ffUL) << 24) | \ 00117 (((pfiu32)(x) & (pfiu32)0x0000ff00UL) << 8) | \ 00118 (((pfiu32)(x) & (pfiu32)0x00ff0000UL) >> 8) | \ 00119 (((pfiu32)(x) & (pfiu32)0xff000000UL) >> 24) )) 00120 00121 #define pfi_htof32(x) PFI_BSWAP32 (x) 00122 #define pfi_ftoh32(x) PFI_BSWAP32 (x) 00123 #define pfi_htof16(x) PFI_BSWAP16 (x) 00124 #define pfi_ftoh16(x) PFI_BSWAP16 (x) 00125 00126 #else 00127 00128 #define pfi_htof32(x) (x) 00129 #define pfi_ftoh32(x) (x) 00130 #define pfi_htof16(x) (x) 00131 #define pfi_ftoh16(x) (x) 00132 00133 #endif /* PFI_BYTE_SWAP */ 00134 00136 enum { pfi_grey = 0, pfi_rgb, pfi_yuv, pfi_unknown }; 00137 00138 00139 /*@-exportlocal@*/ 00140 int pfi_getv (FILE *stream, /*@exposed@*//*@out@*/double *valp); 00141 int pfi_putv (FILE *stream, double val); 00142 int pfi_properties (FILE *stream, int *rows, int *cols, 00143 int *colors, int *colormodel); 00144 /*@null@*//*@only@*/double *pfi_read (FILE *stream, int *rows, int *cols, 00145 int *colors, int *colormodel); 00146 int pfi_write (FILE *stream, double *buf, int rows, int cols, 00147 int colors, int colormodel, char *fname); 00148 00149 DLL_EXPORT int pfi_read_name (char *name, int rows, int cols, int colors, 00150 double *result); 00151 /*@=exportlocal@*/ 00152 00153 00154 DLL_EXPORT int pfi_write_name (char *name, double *buf, int rows, 00155 int cols, int colors, int colormodel); 00156 DLL_EXPORT int pfi_properties_name (char *name, int *rows, int *cols, 00157 int *colors, int *colormodel); 00158 #ifdef __cplusplus 00159 } 00160 #endif /* __cplusplus */ 00161 #endif /* PFI_H__ */
1.7.6.1