Image Interpolation with Contour Stencils
|
00001 00050 #ifndef _BASIC_H_ 00051 #define _BASIC_H_ 00052 00053 #include <math.h> 00054 #include <stdio.h> 00055 #include <stdlib.h> 00056 00057 00058 /* Memory management */ 00060 #define Malloc(s) MallocWithErrorMessage(s) 00061 void *MallocWithErrorMessage(size_t Size); 00063 #define Realloc(p, s) ReallocWithErrorMessage(p, s) 00064 void *ReallocWithErrorMessage(void *Ptr, size_t Size); 00066 #define Free(p) free(p) 00067 00068 00069 /* Portable integer types */ 00070 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 00071 00072 /* Windows system: Use __intN types to define uint8_t, etc. */ 00073 typedef unsigned __int8 uint8_t; 00074 typedef unsigned __int16 uint16_t; 00075 typedef unsigned __int32 uint32_t; 00076 typedef __int8 int8_t; 00077 typedef __int16 int16_t; 00078 typedef __int32 int32_t; 00079 00080 #else 00081 00082 /* UNIX system: Use stdint to define uint8_t, etc. */ 00083 #include <stdint.h> 00084 00085 #endif 00086 00087 00088 /* Math constants (Hart & Cheney) */ 00089 #ifndef M_2PI 00090 00091 #define M_2PI 6.28318530717958647692528676655900576 00092 #endif 00093 #ifndef M_PI 00094 00095 #define M_PI 3.14159265358979323846264338327950288 00096 #endif 00097 #ifndef M_PI_2 00098 00099 #define M_PI_2 1.57079632679489661923132169163975144 00100 #endif 00101 #ifndef M_PI_4 00102 00103 #define M_PI_4 0.78539816339744830961566084581987572 00104 #endif 00105 #ifndef M_PI_8 00106 00107 #define M_PI_8 0.39269908169872415480783042290993786 00108 #endif 00109 #ifndef M_SQRT2 00110 00111 #define M_SQRT2 1.41421356237309504880168872420969808 00112 #endif 00113 #ifndef M_1_SQRT2 00114 00115 #define M_1_SQRT2 0.70710678118654752440084436210484904 00116 #endif 00117 #ifndef M_E 00118 00119 #define M_E 2.71828182845904523536028747135266250 00120 #endif 00121 #ifndef M_LOG2E 00122 00123 #define M_LOG2E 1.44269504088896340735992468100189213 00124 #endif 00125 #ifndef M_LOG10E 00126 00127 #define M_LOG10E 0.43429448190325182765112891891660508 00128 #endif 00129 #ifndef M_LN2 00130 00131 #define M_LN2 0.69314718055994530941723212145817657 00132 #endif 00133 #ifndef M_LN10 00134 00135 #define M_LN10 2.30258509299404568401799145468436421 00136 #endif 00137 #ifndef M_EULER 00138 00139 #define M_EULER 0.57721566490153286060651209008240243 00140 #endif 00141 00143 #define ROUND(X) (floor((X) + 0.5)) 00144 00146 #define ROUNDF(X) (floor((X) + 0.5f)) 00147 00148 00149 #ifdef __GNUC__ 00150 #ifndef ATTRIBUTE_UNUSED 00151 00152 #define ATTRIBUTE_UNUSED __attribute__((unused)) 00153 #endif 00154 #ifndef ATTRIBUTE_ALWAYSINLINE 00155 00156 #define ATTRIBUTE_ALWAYSINLINE __attribute__((always_inline)) 00157 #endif 00158 #else 00159 #define ATTRIBUTE_UNUSED 00160 #define ATTRIBUTE_ALWAYSINLINE 00161 #endif 00162 00163 00164 /* Error messaging */ 00165 void ErrorMessage(const char *Format, ...); 00166 00167 /* Timer function */ 00168 unsigned long Clock(); 00169 00170 #endif /* _BASIC_H_ */