00001
00002
00003
00004
00005
00016
00017 #ifndef GX_IMGEXT_INCL
00018 #define GX_IMGEXT_INCL
00019
00020 #include "gxsd.h"
00021 #include "gximage.h"
00022 #include "gxtrafo.h"
00023
00024 #ifdef GX_NAMESPACES
00025 namespace gx {
00026 #endif
00027
00028 #ifdef GX_DOTNET
00029 #pragma managed
00030 #endif
00031
00033 GX_ENUM GX_COLORADJUST_FLAGS {
00034 GX_COLORADJUST_BRIGHTNESS_BASIC = 1,
00035 GX_COLORADJUST_BRIGHTNESS_ADVANCED = 2,
00036 GX_COLORADJUST_CONTRAST_BASIC = 4,
00037 GX_COLORADJUST_CONTRAST_ADVANCED = 8,
00038 };
00039
00041 GX_ENUM GX_COMPOSE_FLAGS {
00042 GX_COMPOSE_DONT_ENLARGE_IMAGE = 0x01,
00043 GX_COMPOSE_ENLARGE_IMAGE = 0x02,
00044 GX_COMPOSE_ALPHA = 0x04,
00045 GX_COMPOSE_WEIGHTING = 0x08,
00046 };
00047
00049 GX_ENUM GX_TEXT_FLAGS {
00050 GX_TEXT_ITALIC = 0x01,
00051 GX_TEXT_STRAIGHT = 0x02,
00052 GX_TEXT_BOLD = 0x10,
00053 GX_TEXT_NORMAL = 0x20,
00054 GX_TEXT_THIN = 0x30,
00055 };
00056
00057
00058 #if defined(GX_DOTNET) && !defined(GX_MANUAL)
00059 #pragma unmanaged
00060 #define gxPNT _gxPNT
00061 #define gxPG4 _gxPG4
00062 #endif
00063
00064
00065 #if !defined(GX_SWIGIF) && !defined(GX_MANUAL)
00066
00067 enum {
00068 GX_CALL_COLORADJUST = GX_CALL_GROUP_GX_IMGEXT,
00069 GX_CALL_COLORMIXER = GX_CALL_GROUP_GX_IMGEXT+1,
00070 GX_CALL_IMAGEDIFFERENCE = GX_CALL_GROUP_GX_IMGEXT+2,
00071 GX_CALL_IMAGETRANSFORM = GX_CALL_GROUP_GX_IMGEXT+3,
00072 GX_CALL_IMAGEFTRANSFORM = GX_CALL_GROUP_GX_IMGEXT+4,
00073 GX_CALL_IMAGECOMPOSE = GX_CALL_GROUP_GX_IMGEXT+5,
00074 GX_CALL_DRAWTEXT = GX_CALL_GROUP_GX_IMGEXT+6,
00075 };
00076
00077
00079 struct GX_PARM_COLORADJUST {
00080 gxIMAGE *image;
00081 float contrast;
00082 float brightness;
00083 float saturation;
00084 float gamma;
00085 int flags;
00086 };
00087
00089 struct GX_PARM_COLORMIXER {
00090 gxIMAGE *target;
00091 gxIMAGE *source;
00092 int r1;
00093 int g1;
00094 int b1;
00095 int r2;
00096 int g2;
00097 int b2;
00098 int r3;
00099 int g3;
00100 int b3;
00101 };
00102
00104 struct GX_PARM_IMAGEDIFFERENCE {
00105 gxIMAGE *target;
00106 gxIMAGE *source1;
00107 gxIMAGE *source2;
00108 };
00109
00111 struct GX_PARM_IMAGETRANSFORM {
00112 gxIMAGE *target;
00113 gxIMAGE *source;
00114 gxPG4 area;
00115 void *bgcolor;
00116 };
00117
00119 struct GX_PARM_IMAGEFTRANSFORM {
00120 gxIMAGE *target;
00121 gxIMAGE *source;
00122 gxTRAFO *trafo;
00123 void *bgcolor;
00124 };
00125
00127 struct GX_PARM_IMAGECOMPOSE {
00128 gxIMAGE *target;
00129 gxIMAGE *upper;
00130 gxIMAGE *lower;
00131 gxPNT position;
00132 float alpha_u;
00133 float alpha_l;
00134 int flags;
00135 void *bgcolor;
00136 };
00137
00140 struct GX_PARM_DRAWTEXT {
00141 gxIMAGE *image;
00142 const char *text;
00143 gxPNT position;
00144 const char *fonttype;
00145 int fontheight;
00146 int fontwidth;
00147 void *txtcolor;
00148 int flags;
00149 };
00150
00151 #endif
00152
00153
00154 #if !defined(NO_GX_FUNCTIONS) && !defined(GX_SWIGIF)
00155
00156
00157
00161
00162
00163
00185 inline int gx_coloradjust(gxHANDLE imgexthandle, gxIMAGE *image,
00186 float contrast GX_DEFARG(0), float brightness GX_DEFARG(0), float saturation GX_DEFARG(0),
00187 float gamma GX_DEFARG(1), int flags GX_DEFARG(0))
00188 {
00189 struct GX_PARM_COLORADJUST col;
00190 assert(image);
00191 col.image = image;
00192 col.contrast = contrast;
00193 col.brightness = brightness;
00194 col.saturation = saturation;
00195 col.gamma = gamma;
00196 col.flags = flags;
00197 return gx_call(imgexthandle, GX_CALL_COLORADJUST, &col);
00198 }
00199
00200
00223 inline int gx_colormixer(gxHANDLE imgexthandle, gxIMAGE *target,
00224 gxIMAGE *source, int r1, int g1, int b1,
00225 int r2 GX_DEFARG(0), int g2 GX_DEFARG(0), int b2 GX_DEFARG(0),
00226 int r3 GX_DEFARG(0), int g3 GX_DEFARG(0), int b3 GX_DEFARG(0))
00227 {
00228 struct GX_PARM_COLORMIXER col;
00229 assert(target);
00230 assert(source);
00231 col.target = target;
00232 col.source = source;
00233 col.r1 = r1;
00234 col.g1 = g1;
00235 col.b1 = b1;
00236 col.r2 = r2;
00237 col.g2 = g2;
00238 col.b2 = b2;
00239 col.r3 = r3;
00240 col.g3 = g3;
00241 col.b3 = b3;
00242 return gx_call(imgexthandle, GX_CALL_COLORMIXER, &col);
00243 }
00244
00245
00254 inline int gx_imagedifference(gxHANDLE imgexthandle, gxIMAGE *target,
00255 gxIMAGE *source1, gxIMAGE *source2)
00256 {
00257 struct GX_PARM_IMAGEDIFFERENCE idf;
00258 assert(target);
00259 assert(source1);
00260 assert(source2);
00261 idf.target = target;
00262 idf.source1 = source1;
00263 idf.source2 = source2;
00264 return gx_call(imgexthandle, GX_CALL_IMAGEDIFFERENCE, &idf);
00265 }
00266
00267
00277 inline int gx_imagetransform(gxHANDLE imgexthandle, gxIMAGE *target,
00278 gxIMAGE *source, gxPG4 area, void *bgcolor GX_DEFARG(0))
00279 {
00280 struct GX_PARM_IMAGETRANSFORM itr;
00281 assert(target);
00282 assert(source);
00283 itr.target = target;
00284 itr.source = source;
00285 itr.area = area;
00286 itr.bgcolor = bgcolor;
00287 return gx_call(imgexthandle, GX_CALL_IMAGETRANSFORM, &itr);
00288 }
00289
00290
00300 inline int gx_imageftransform(gxHANDLE imgexthandle, gxIMAGE *target,
00301 gxIMAGE *source, gxTRAFO *trafo, void *bgcolor GX_DEFARG(0))
00302 {
00303 struct GX_PARM_IMAGEFTRANSFORM ftr;
00304 assert(target);
00305 assert(source);
00306 assert(trafo);
00307 ftr.target = target;
00308 ftr.source = source;
00309 ftr.trafo = trafo;
00310 ftr.bgcolor = bgcolor;
00311 return gx_call(imgexthandle, GX_CALL_IMAGEFTRANSFORM, &ftr);
00312 }
00313
00314
00328 inline int gx_imagecompose(gxHANDLE imgexthandle, gxIMAGE *target,
00329 gxIMAGE *upper, gxIMAGE *lower, gxPNT position,
00330 float alpha_u GX_DEFARG(1), float alpha_l GX_DEFARG(1),
00331 int flags GX_DEFARG(0), void *bgcolor GX_DEFARG(0))
00332 {
00333 struct GX_PARM_IMAGECOMPOSE ic;
00334 assert(target);
00335 assert(upper);
00336 assert(lower);
00337 ic.target = target;
00338 ic.upper = upper;
00339 ic.lower = lower;
00340 ic.position = position;
00341 ic.alpha_u = alpha_u;
00342 ic.alpha_l = alpha_l;
00343 ic.flags = flags;
00344 ic.bgcolor = bgcolor;
00345 return gx_call(imgexthandle, GX_CALL_IMAGECOMPOSE, &ic);
00346 }
00347
00348
00363 inline int gx_drawtext(gxHANDLE imgexthandle, gxIMAGE *image, const char *text,
00364 gxPNT position, const char *fonttype, int fontheight, int fontwidth,
00365 void *txtcolor, unsigned int flags)
00366 {
00367 struct GX_PARM_DRAWTEXT dt;
00368 assert(text);
00369 assert(txtcolor);
00370 dt.image = image;
00371 dt.text = text;
00372 dt.position = position;
00373 dt.fonttype = fonttype;
00374 dt.fontheight = fontheight;
00375 dt.fontwidth = fontwidth;
00376 dt.txtcolor = txtcolor;
00377 dt.flags = flags;
00378 return gx_call(imgexthandle, GX_CALL_DRAWTEXT, &dt);
00379 }
00380
00381
00383
00384 #endif
00385
00386 #ifdef GX_DOTNET
00387 #pragma managed
00388 #undef gxPNT
00389 #undef gxPG4
00390 #endif
00391
00392
00393
00394 #if !defined(NO_GX_CLASSES)
00395
00397 GX_CLASS gxImgExt : public gxHandle
00398 {
00399
00400 public:
00401
00403 gxImgExt() gxFuncThrowsError {
00404 #ifndef GX_DOTNET
00405 if(!gx_openmodule(this, L"gximgext", 0)) gxthrow;
00406 #else
00407 GX_GETHANDLE(h);
00408 if(!gx_openmodule(&h, L"gximgext", 0)) gxthrow;
00409 _set_handle(h.handle);
00410 #endif
00411 }
00412
00413
00434 inline bool ColorAdjust(gxImage GX_REF_CLASS(image), float contrast GX_DEFARG(0), float brightness GX_DEFARG(0),
00435 float saturation GX_DEFARG(0), float gamma GX_DEFARG(1), int flags GX_DEFARG(0)) gxFuncThrowsError {
00436 GX_GETHANDLE(h);
00437 GX_GETIMAGE2(_image, image);
00438 bool st = gx_coloradjust(h, _image, contrast, brightness, saturation, gamma, flags) != 0;
00439 gxcondthrow(!st);
00440 return st;
00441 }
00442
00443
00461 inline bool Contrast(gxImage GX_REF_CLASS(image), float contrast, int flags GX_DEFARG(0)) gxFuncThrowsError {
00462 GX_GETHANDLE(h);
00463 GX_GETIMAGE2(_image,image);
00464 bool st = gx_coloradjust(h, _image, contrast, 0, 0, 1.f, flags) != 0;
00465 gxcondthrow(!st);
00466 return st;
00467 }
00468
00469
00485 inline bool Brightness(gxImage GX_REF_CLASS(image), float brightness, int flags GX_DEFARG(0)) gxFuncThrowsError {
00486 GX_GETHANDLE(h);
00487 GX_GETIMAGE2(_image, image);
00488 bool st = gx_coloradjust(h, _image, 0, brightness, 0, 1.f, flags) != 0;
00489 gxcondthrow(!st);
00490 return st;
00491 }
00492
00493
00510 inline bool Saturation(gxImage GX_REF_CLASS(image), float saturation) gxFuncThrowsError {
00511 GX_GETHANDLE(h);
00512 GX_GETIMAGE2(_image, image);
00513 bool st = gx_coloradjust(h, _image, 0, 0, saturation, 1.f, 0) != 0;
00514 gxcondthrow(!st);
00515 return st;
00516 }
00517
00518
00528 inline bool Gamma(gxImage GX_REF_CLASS(image), float gamma) gxFuncThrowsError {
00529 GX_GETHANDLE(h);
00530 GX_GETIMAGE2(_image, image);
00531 bool st = gx_coloradjust(h, _image, 0, 0, 0, gamma, 0) != 0;
00532 gxcondthrow(!st);
00533 return st;
00534 }
00535
00536
00558 inline bool ColorMixer(gxImage GX_REF_CLASS(target), gxImage GX_REF_CLASS(source),
00559 int r1, int g1, int b1,
00560 int r2 GX_DEFARG(0), int g2 GX_DEFARG(0), int b2 GX_DEFARG(0),
00561 int r3 GX_DEFARG(0), int g3 GX_DEFARG(0), int b3 GX_DEFARG(0)) gxFuncThrowsError {
00562 GX_GETHANDLE(h);
00563 GX_GETIMAGE2(_target, target);
00564 GX_GETIMAGE2(_source, source);
00565 bool st = gx_colormixer(h, _target, _source, r1, g1, b1, r2, g2, b2, r3, g3, b3) != 0;
00566 gxcondthrow(!st);
00567 return st;
00568 }
00569
00570
00578 inline bool Difference(gxImage GX_REF_CLASS(target), gxImage GX_REF_CLASS(source1), gxImage GX_REF_CLASS(source2)) gxFuncThrowsError {
00579 GX_GETHANDLE(h);
00580 GX_GETIMAGE2(_target, target);
00581 GX_GETIMAGE2(_source1, source1);
00582 GX_GETIMAGE2(_source2, source2);
00583 bool st = gx_imagedifference(h, _target, _source1, _source2) != 0;
00584 gxcondthrow(!st);
00585 return st;
00586 }
00587
00588 #if !defined(GX_SWIG) && !defined(GX_DOTNET)
00589
00597 inline bool Transform(gxImage & target, gxImage & source, gxPG4 area) gxFuncThrowsError {
00598 GX_GETHANDLE(h);
00599 GX_GETIMAGE2(_target, target);
00600 GX_GETIMAGE2(_source, source);
00601 bool st = gx_imagetransform(h, _target, _source, area) != 0;
00602 gxcondthrow(!st);
00603 return st;
00604 }
00605
00606
00614 inline bool FTransform(gxImage & target, gxImage & source, gxTrafo & trafo) gxFuncThrowsError {
00615 GX_GETHANDLE(h);
00616 GX_GETIMAGE2(_target, target);
00617 GX_GETIMAGE2(_source, source);
00618 bool st = gx_imageftransform(h, _target, _source, trafo) != 0;
00619 gxcondthrow(!st);
00620 return st;
00621 }
00622
00623
00635 inline bool Compose(gxImage & target, gxImage & upper, gxImage & lower, gxPNT position,
00636 float alpha_u GX_DEFARG(1), float alpha_l GX_DEFARG(1), int flags GX_DEFARG(0)) gxFuncThrowsError {
00637 GX_GETHANDLE(h);
00638 GX_GETIMAGE2(_target, target);
00639 GX_GETIMAGE2(_upper, upper);
00640 GX_GETIMAGE2(_lower, lower);
00641 bool st = gx_imagecompose(h, _target, _upper, _lower, position, alpha_u, alpha_l, flags) != 0;
00642 gxcondthrow(!st);
00643 return st;
00644 }
00645
00646
00659 inline bool DrawText(gxImage & image, const char *text, gxPNT position, const char *fonttype,
00660 int fontheight, int fontwidth, void *txtcolor, unsigned int flags) gxFuncThrowsError {
00661 GX_GETHANDLE(h);
00662 GX_GETIMAGE2(_image, image);
00663
00664 bool st = gx_drawtext(h, _image, text, position, fonttype, fontheight,
00665 fontwidth, txtcolor, flags) != 0;
00666 gxcondthrow(!st);
00667 return st;
00668 }
00669
00670 #endif
00671
00672 };
00673
00674
00675 #endif
00676
00677 #ifdef GX_NAMESPACES
00678 }
00679 #endif
00680
00681 #endif
00682