00001
00077 #ifndef INC_MI32_COLORBAL_H
00078 #define INC_MI32_COLORBAL_H
00079
00080 #ifndef INC_MI32_XBASE_H
00081 #include <mi32/xbase.h>
00082 #endif
00083
00084 #ifndef INC_MI32_MICALLBACKLIST_H
00085 #include <mi32/micallbacklist.h>
00086 #endif
00087
00088 #ifndef INC_MI32_SERIALIZERBASE_H
00089 #include <mi32/serializerbase.h>
00090 #endif
00091
00092 #ifndef INC_MEMORY_H
00093 #define INC_MEMORY_H
00094 #include <memory.h>
00095 #endif
00096
00097 #ifndef GENERATING_DOXYGEN_OUTPUT
00098
00099 struct COLOR;
00100 struct PRINTGAMMA;
00101 #endif // GENERATING_DOXYGEN_OUTPUT
00102
00103
00104
00105
00106
00107 struct CBPARMS {
00108
00109 CBPARMS() {
00110 memset(this, 0, sizeof(CBPARMS));
00111 }
00112
00113 ~CBPARMS() {}
00114
00116 double spval[6];
00117 double saval[6];
00118 double ssval[6];
00119 double hsval[6];
00120 double int_val;
00121 double con_val;
00122 double sat_val;
00123 UINT32 flags;
00124
00126 bool IsIdentity (void) const;
00127
00129 static const SERIALIZERITEM* GetSerialItemDef();
00130 };
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 #define CBAL_ValsSet 0x00000001
00142 #define CBAL_AdjustHue 0x00000002
00143 #define CBAL_AdjustInt 0x00000004
00144 #define CBAL_AdjustSat 0x00000008
00145 #define CBAL_AdjustHueShift 0x00000010
00146 #define CBAL_AdjustMask (CBAL_AdjustHue|CBAL_AdjustInt|CBAL_AdjustSat|CBAL_AdjustHueShift)
00147 #define CBAL_ForceGray 0x00000020
00148
00149
00151
00152
00153 struct MCBALCALLBACKSTRUCT : MICALLBACKLIST::ANYCALLBACKSTRUCT {
00154 MCBALCALLBACKSTRUCT(int reason);
00155
00157 MXDHANDLE dhandle;
00158 Widget ColorBalanceForm;
00159 Widget retdialog;
00160 CBPARMS *cbal;
00161 PRINTGAMMA *cont;
00162 int mode;
00163 };
00164
00165 class COLORBALANCE {
00166 public:
00167
00168
00170 COLORBALANCE (
00171 ) {
00172 m_is_identity = 1;
00173 }
00174
00176 COLORBALANCE (
00177 const CBPARMS &p
00178 ) {
00179 SetParms(p);
00180 }
00181
00183 ~COLORBALANCE() {}
00184
00185
00186
00188 void TransBuffers (
00189 UINT8 *rbuf,
00190 UINT8 *gbuf,
00191 UINT8 *bbuf,
00192 int count
00193 ) const;
00194
00199 void TransBuffers (
00200 int *rbuf,
00201 int *gbuf,
00202 int *bbuf,
00203 int count
00204 ) const;
00205
00207 void TransRGB (
00208 UINT8 *buf,
00209 int count,
00210 int BytesPerPixel = 3
00211 ) const;
00212
00214 void TransCOLORs (
00215 COLOR *buf,
00216 int count
00217 ) const;
00218
00220 void SetParms (
00221 const CBPARMS &
00222 );
00223
00225 bool IsIdentity (
00226 ) const {
00227 return (m_is_identity);
00228 }
00229
00230 private:
00231 #ifndef GENERATING_DOXYGEN_OUTPUT
00232
00233
00234 double m_htrans[360], m_div_255[256];
00235 UINT8 m_igamma[256];
00236 UINT8 m_sgamma[256];
00237 INT8 m_hi_adj[360];
00238 INT8 m_hs_adj[360];
00239 bool m_need_h;
00240 bool m_need_i;
00241 bool m_need_s;
00242 bool m_no_sat;
00243 bool m_is_identity;
00244
00246 void (COLORBALANCE::*TransFunc) (
00247 UINT8 *rbuf,
00248 UINT8 *gbuf,
00249 UINT8 *bbuf,
00250 int count
00251 ) const;
00252
00254 void TransZeroSat (
00255 UINT8 *rbuf,
00256 UINT8 *gbuf,
00257 UINT8 *bbuf,
00258 int count
00259 ) const;
00260
00262 void TransComplete (
00263 UINT8 *rbuf,
00264 UINT8 *gbuf,
00265 UINT8 *bbuf,
00266 int count
00267 ) const;
00268
00270 void TransForceGray (
00271 UINT8 *rbuf,
00272 UINT8 *gbuf,
00273 UINT8 *bbuf,
00274 int count
00275 ) const;
00276
00278 void ComputeGamma (
00279 UINT8 *table,
00280 double gamma
00281 ) const;
00282
00283 #endif // GENERATING_DOXYGEN_OUTPUT
00284 };
00285
00286
00288
00289
00290 extern "C" {
00291
00292 #ifdef X_NATIVE
00293
00295 int MxColorBalanceForm (
00296 Widget parent,
00297 CBPARMS *cp,
00298 PRINTGAMMA *gamma,
00299 Widget *pForm,
00300 XTARGS& args,
00301 UINT32 flags
00302 );
00303
00305 int MxColorBalanceFormSetParms (
00306 Widget form,
00307 CBPARMS *cp,
00308 PRINTGAMMA *gamma
00309 );
00310
00312 void MxColorBalanceFormSetTestCallback (
00313 Widget form,
00314 MICALLBACKLIST::CALLBACKFUNC func,
00315 void *cbdata
00316 );
00317
00331 int MxdColorBalanceCreate (
00332 Widget pwidget,
00333 MXDHANDLE *dhandle,
00334 char *dialogname,
00335 CBPARMS *cbparms,
00336 UINT32 dialogflags
00337 );
00338
00344 int MxdColorBalanceOpen (
00345 MXDHANDLE dhandle
00346 );
00347
00351 int MxdColorBalanceClose (
00352 MXDHANDLE dhandle
00353 );
00354
00358 int MxdColorBalanceDestroy (
00359 MXDHANDLE dhandle
00360 );
00361
00365 int MxdColorBalanceGetParms (
00366 MXDHANDLE dhandle,
00367 CBPARMS *cbparms,
00368 UINT32 flags
00369 );
00370
00375 int MxdColorBalanceSetParms (
00376 MXDHANDLE dhandle,
00377 CBPARMS *cbparms,
00378 UINT32 flags
00379 );
00380
00382 int MxdColorBalanceAddCallback (
00383 MXDHANDLE dhandle,
00384 MICALLBACKLIST::CALLBACKFUNC cbfunc,
00385 void *cbdata,
00386 UINT32 reason
00387 );
00388
00390 int MxdColorBalanceRemoveCallback (
00391 MXDHANDLE dhandle,
00392 MICALLBACKLIST::CALLBACKFUNC cbfunc,
00393 void *cbdata,
00394 UINT32 reason
00395 );
00396
00397 #endif
00398
00400 void HISTransCompHueTable (
00401 short *htrans,
00402 const double *sval,
00403 const double *hsval
00404 );
00405
00407 void HISTransCompHueAmpTable (
00408 signed char *atrans,
00409 const double *sval
00410 );
00411
00417 int McbalInit (
00418 CBPARMS *parms,
00419 void **handle
00420 );
00421
00423 void McbalStop (
00424 void *handle
00425 );
00426
00431 void McbalTransBuffers (
00432 void *handle,
00433 UINT8 *rbuf,
00434 UINT8 *gbuf,
00435 UINT8 *bbuf,
00436 int count
00437 );
00438
00441 void McbalTransCOLORs (
00442 void *handle,
00443 COLOR *colors,
00444 int count
00445 );
00446
00453 void McbalTransInt8 (
00454 void *handle,
00455 int *rbuf,
00456 int *gbuf,
00457 int *bbuf,
00458 int count
00459 );
00460
00462 void McbalCompHueTable (
00463 short *htrans,
00464 double *sval,
00465 double *hsval
00466 );
00467
00469 void McbalCompHueAmpTable (
00470 signed char *atrans,
00471 double *sval
00472 );
00473
00475 int McbalParmIsIdentity(CBPARMS *);
00476
00482 int McbalIsIdentity(
00483 void *parms
00484 );
00485
00486 }
00487
00488 #endif