00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #include "camtypes.h"
00102
00103 #include "bevfill.h"
00104
00105 CC_IMPLEMENT_DYNAMIC(CBevelFills, CCObject)
00106 CC_IMPLEMENT_DYNAMIC(CBevelFill, CCObject)
00107 CC_IMPLEMENT_DYNAMIC(CBevelFillFlat, CBevelFill)
00108 CC_IMPLEMENT_DYNAMIC(CBevelFillRound, CBevelFill)
00109 CC_IMPLEMENT_DYNAMIC(CBevelFillSquare, CBevelFill)
00110 CC_IMPLEMENT_DYNAMIC(CBevelFillFrame, CBevelFill)
00111 CC_IMPLEMENT_DYNAMIC(CBevelFillSmooth, CBevelFill)
00112 CC_IMPLEMENT_DYNAMIC(CBevelFillRuffle, CBevelFill)
00113 CC_IMPLEMENT_DYNAMIC(CBevelFillPoint, CBevelFill)
00114
00115 #define new CAM_DEBUG_NEW
00116
00117
00118 const double SplitValue = 213;
00119
00120 void CBevelFill::EnsureValueRange(double *value)
00121 {
00122 if (*value > 254)
00123 {
00124 *value = 254;
00125 }
00126 else if (*value < 1)
00127 {
00128 *value = 1;
00129 }
00130 }
00131
00133
00134
00135 CBevelFills::CBevelFills()
00136 {
00137 SetUpFills();
00138 }
00139
00140 CBevelFills::~CBevelFills()
00141 {
00142 for (INT32 i = 0 ; i < m_NumFills; i++)
00143 {
00144 TRACE( _T("deleting bevel fill %d\n"), i);
00145 delete m_pBevFills[i];
00146 }
00147
00148 delete m_pBevFills;
00149 m_pBevFills = NULL;
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 BOOL CBevelFills::SetUpFills()
00166 {
00167
00168 m_NumFills = 7;
00169
00170 m_pBevFills = new CBevelFill *[m_NumFills];
00171 m_pBevFills[0] = new CBevelFillFlat;
00172
00173 m_pBevFills[1] = new CBevelFillRound;
00174
00175 m_pBevFills[2] = new CBevelFillSquare;
00176
00177 m_pBevFills[3] = new CBevelFillFrame;
00178
00179 m_pBevFills[4] = new CBevelFillSmooth;
00180
00181 m_pBevFills[5] = new CBevelFillPoint;
00182
00183 m_pBevFills[6] = new CBevelFillRuffle;
00184
00185 return TRUE;
00186 }
00187
00188 COLORREF CBevelFills::CalcPixelValue(BYTE value, INT32 bevType, double Pos, INT32 Contrast)
00189 {
00190 if (Pos < 0.00)
00191 {
00192 Pos = 0.00;
00193 }
00194
00195 if (Pos >= 1.00)
00196 {
00197 Pos = 1.00;
00198 }
00199
00200 if (bevType < 0 || bevType >= m_NumFills)
00201 {
00202 return m_pBevFills[0]->CalcPixelValue(value, Pos, Contrast);
00203 }
00204
00205 return m_pBevFills[bevType]->CalcPixelValue(value, Pos, Contrast);
00206 }
00207
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 COLORREF CBevelFillFlat::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00225 {
00226 double RValue = value;
00227 double GValue = value;
00228 double BValue = value;
00229 double AValue = value;
00230
00231 if (AValue < SplitValue)
00232 {
00233 AValue *= 255.0 / SplitValue;
00234 }
00235 else
00236 {
00237 AValue = 255.0 - AValue;
00238 AValue *= 255.0 / (255.0 - SplitValue);
00239
00240 AValue = 1.0 - (AValue / 255.0);
00241 AValue *= AValue;
00242 AValue = (1.0 - AValue) * 255.0;
00243 }
00244
00245 AValue *= 200.0 / 255.0;
00246
00247 RValue += 0.5;
00248 GValue += 0.5;
00249 BValue += 0.5;
00250
00251 EnsureValueRange(&AValue);
00252
00253 BYTE RByte = (BYTE)RValue;
00254 BYTE GByte = (BYTE)GValue;
00255 BYTE BByte = (BYTE)BValue;
00256 BYTE AByte = (BYTE)AValue;
00257
00258 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 COLORREF CBevelFillRound::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00275 {
00276 double RValue = value;
00277 double GValue = value;
00278 double BValue = value;
00279 double AValue = value;
00280
00281 double Gradient = 0;
00282
00283
00284 if (Pos <= 0.5)
00285 {
00286 Pos = Pos / 0.5;
00287
00288 Gradient = 128 - RValue;
00289 RValue = RValue + (Gradient * Pos);
00290 }
00291 else
00292 {
00293 Pos = 1.0 - Pos;
00294 RValue = 255.0 - RValue;
00295
00296 Pos = Pos / 0.5;
00297
00298 Gradient = 128 - RValue;
00299 RValue = RValue + (Gradient * Pos);
00300 }
00301
00302 BYTE RByte = (BYTE)RValue;
00303 BYTE GByte = (BYTE)RValue;
00304 BYTE BByte = (BYTE)RValue;
00305 BYTE AByte = (BYTE)AValue;
00306
00307 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00308 }
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 COLORREF CBevelFillSquare::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00324 {
00325 double RValue = value;
00326 double GValue = value;
00327 double BValue = value;
00328 double AValue = value;
00329
00330 double Gradient = 0;
00331
00332
00333 if (Pos <= 0.3)
00334 {
00335
00336 }
00337 else if (Pos >= 0.7)
00338 {
00339 RValue = 255.0 - RValue;
00340 }
00341 else
00342 {
00343 RValue = 128.0;
00344 }
00345
00346 BYTE RByte = (BYTE)RValue;
00347 BYTE GByte = (BYTE)RValue;
00348 BYTE BByte = (BYTE)RValue;
00349 BYTE AByte = (BYTE)AValue;
00350
00351 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 COLORREF CBevelFillFrame::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00368 {
00369 Pos = 1.0 - Pos;
00370
00371 double RValue = value;
00372 double GValue = value;
00373 double BValue = value;
00374 double AValue = value;
00375
00376 double kValue = value;
00377
00378
00379 if (value <= 128)
00380 {
00381 kValue = 128.0 - kValue;
00382 kValue *= (1.0 - Pos);
00383 kValue = 128.0 - kValue;
00384 }
00385 else
00386 {
00387 kValue -= 127.0;
00388 kValue *= (1.0 - Pos);
00389 kValue += 127.0;
00390 }
00391
00392 RValue = kValue;
00393 GValue = kValue;
00394 BValue = kValue;
00395 AValue = kValue;
00396
00397 BYTE RByte = (BYTE)RValue;
00398 BYTE GByte = (BYTE)GValue;
00399 BYTE BByte = (BYTE)BValue;
00400 BYTE AByte = (BYTE)AValue;
00401
00402 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00403 }
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 COLORREF CBevelFillSmooth::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00419 {
00420 double RValue = value;
00421 double GValue = value;
00422 double BValue = value;
00423 double AValue = value;
00424
00425 double kValue = value;
00426
00427
00428 if (value <= 128)
00429 {
00430 kValue = 128.0 - kValue;
00431 kValue *= (1.0 - Pos);
00432 kValue = 128.0 - kValue;
00433 }
00434 else
00435 {
00436 kValue -= 127.0;
00437 kValue *= (1.0 - Pos);
00438 kValue += 127.0;
00439 }
00440
00441 RValue = kValue;
00442 GValue = kValue;
00443 BValue = kValue;
00444 AValue = kValue;
00445
00446 BYTE RByte = (BYTE)RValue;
00447 BYTE GByte = (BYTE)GValue;
00448 BYTE BByte = (BYTE)BValue;
00449 BYTE AByte = (BYTE)AValue;
00450
00451 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 COLORREF CBevelFillPoint::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00468 {
00469 double RValue = value;
00470 double GValue = value;
00471 double BValue = value;
00472 double AValue = value;
00473
00474 double kValue = value;
00475
00476 if (Pos < 0.5)
00477 {
00478
00479 }
00480 else
00481 {
00482 kValue = 255.0 - kValue;
00483 }
00484
00485 RValue = kValue;
00486 GValue = kValue;
00487 BValue = kValue;
00488 AValue = kValue;
00489
00490 BYTE RByte = (BYTE)RValue;
00491 BYTE GByte = (BYTE)GValue;
00492 BYTE BByte = (BYTE)BValue;
00493 BYTE AByte = (BYTE)AValue;
00494
00495 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00496 }
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512 COLORREF CBevelFillRuffle::CalcPixelValue(BYTE value, double Pos, INT32 Contrast)
00513 {
00514
00515 if (Pos >= 0 && Pos < 0.3)
00516 {
00517 Pos = Pos * (1.0/0.3);
00518 }
00519 else if (Pos >= 0.3 && Pos < 0.6)
00520 {
00521 Pos = (Pos - 0.3) * (1.0 / 0.3);
00522 }
00523 else
00524 {
00525 Pos = (Pos - 0.6) * (1.0 / 0.4);
00526 }
00527
00528 double RValue = value;
00529 double GValue = value;
00530 double BValue = value;
00531 double AValue = value;
00532
00533 double kValue = value;
00534
00535 if (Pos < 0.5)
00536 {
00537
00538 }
00539 else
00540 {
00541 kValue = 255.0 - kValue;
00542 }
00543
00544 RValue = kValue;
00545 GValue = kValue;
00546 BValue = kValue;
00547 AValue = kValue;
00548
00549 BYTE RByte = (BYTE)RValue;
00550 BYTE GByte = (BYTE)GValue;
00551 BYTE BByte = (BYTE)BValue;
00552 BYTE AByte = (BYTE)AValue;
00553
00554 return RByte | (GByte << 8) | (BByte << 16) | (AByte << 24);
00555 }