1 /* $Id$ */ 2 3 #ifndef __IPA_H__ 4 #define __IPA_H__ 5 6 #include <apricot.h> 7 #include <Image.h> 8 9 #ifndef dPROFILE 10 #define dPROFILE SV ** temporary_prf_Sv 11 #endif 12 13 #define createImage(w,h,type) create_object("Prima::Image","iii","width",(w),"height",(h),"type",(type)) 14 #define createNamedImage(w,h,type,name) create_object("Prima::Image","iiis","width",(w),"height",(h),"type",(type),"name",(name)) 15 #define destroyImage(img) Object_destroy((Handle)img) 16 17 #ifndef min 18 #define min(x,y) ((x)<(y) ? (x) : (y)) 19 #endif 20 #ifndef max 21 #define max(x,y) ((x)>(y) ? (x) : (y)) 22 #endif 23 #ifndef sign 24 #define sign(x) ((x)<0 ? -1 : ((x)>0 ? 1 : 0)) 25 #endif 26 27 #define COMBINE_MAXABS 1 28 #define COMBINE_SUMABS 2 29 #define COMBINE_SUM 3 30 #define COMBINE_SQRT 4 31 #define COMBINE_SIGNEDMAXABS 5 32 #define COMBINE_MULTIPLY 6 33 #define COMBINE_FIRST COMBINE_MAXABS 34 #define COMBINE_LAST COMBINE_MULTIPLY 35 36 #define CONV_TRUNCABS 1 37 #define CONV_TRUNC 2 38 #define CONV_SCALE 3 39 #define CONV_SCALEABS 4 40 #define CONV_FIRST CONV_TRUNCABS 41 #define CONV_LAST CONV_SCALEABS 42 43 extern PImage create_compatible_image(PImage,Bool); 44 extern PImage_vmt CImage; 45 46 typedef float Float; 47 typedef double Double; 48 49 #define dPIX_ARGS int x, y, h, w, sls, dls, src_ls, dst_ls, in_type;\ 50 Byte *dsrc, *ddst 51 #define PIX_INITARGS(in,out) \ 52 dsrc = (in)->data;\ 53 sls = (in)->lineSize;\ 54 ddst = (out)->data;\ 55 dls = (out)->lineSize;\ 56 in_type = (in)->type;\ 57 h = (in)->h;\ 58 w = (in)->w; 59 #define PIX_SWITCH switch(in_type) { 60 #define PIX_TYPE2(type1,type2,op) {\ 61 type1 * src = ( type1 *) dsrc;\ 62 type2 * dst = ( type2 *) ddst;\ 63 src_ls=sls/sizeof(type1);\ 64 dst_ls=dls/sizeof(type2);\ 65 for ( y = 0; y < h; y++, dsrc += sls, ddst += dls, src = (type1*)dsrc, dst =(type2*)ddst){\ 66 for ( x = 0; x < w; x++, src++, dst++) {\ 67 *dst = (type2)(op);\ 68 }\ 69 }\ 70 } 71 #define PIX_CASE(type,op) case im##type:\ 72 PIX_TYPE2(type,type,op)\ 73 break 74 #define PIX_CASE2(type1,type2,op) case im##type1:\ 75 PIX_TYPE2(type1,type2,op)\ 76 break 77 #define PIX_END_SWITCH default: croak("%s: unsupported pixel type", method); } 78 #define PIX_BODY(op) \ 79 PIX_CASE(Byte,op);\ 80 PIX_CASE(Short,op);\ 81 PIX_CASE(Long,op);\ 82 PIX_CASE(Float,op);\ 83 PIX_CASE(Double,op); 84 #define PIX_BODY2(type,op) \ 85 PIX_CASE2(Byte,type,op);\ 86 PIX_CASE2(Short,type,op);\ 87 PIX_CASE2(Long,type,op);\ 88 PIX_CASE2(Float,type,op);\ 89 PIX_CASE2(Double,type,op); 90 91 #define PIX_SRC_DST(src,dst,op) \ 92 {\ 93 dPIX_ARGS;\ 94 PIX_INITARGS(src,dst)\ 95 PIX_SWITCH\ 96 PIX_BODY(op)\ 97 PIX_END_SWITCH\ 98 } 99 100 #define PIX_SRC_DST2(src,dst,type,op) \ 101 {\ 102 dPIX_ARGS;\ 103 PIX_INITARGS(src,dst)\ 104 PIX_SWITCH\ 105 PIX_BODY2(type,op)\ 106 PIX_END_SWITCH\ 107 } 108 109 #endif /* __IPA_H__ */ 110