00001
00002
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
00102
00103 #ifndef INC_BFXALU
00104 #define INC_BFXALU
00105
00106
00107 class KernelBitmap;
00108 class OILBitmap;
00109
00110 #ifndef EXCLUDE_FROM_RALPH
00111
00112
00113 #include "tracectl.h"
00114
00115 class GDrawContext;
00116 class BfxALULUT;
00117 class Path;
00118 class String_256;
00119
00120
00121 typedef struct
00122 {
00123 BYTE R;
00124 BYTE G;
00125 BYTE B;
00126 BYTE T;
00127 } AluPix32;
00128
00129 enum BfxSpecialEffect { BFX_SFX_USER, BFX_SFX_ISOLATEPOINTS, BFX_SFX_EDGE, BFX_SFX_HEDGE,
00130 BFX_SFX_VEDGE, BFX_SFX_P45EDGE, BFX_SFX_N45EDGE, BFX_SFX_LAPLACIAN,
00131 BFX_SFX_DIALATION, BFX_SFX_ROBERTS };
00132
00133 class KernelStatistics
00134 {
00135 public:
00136
00137 INT32 N ;
00138 double R ;
00139 double R2 ;
00140 double RX ;
00141 double RY ;
00142 double G ;
00143 double G2 ;
00144 double GX ;
00145 double GY ;
00146 double B ;
00147 double B2 ;
00148 double BX ;
00149 double BY ;
00150 double X ;
00151 double Y ;
00152 double X2 ;
00153 double Y2 ;
00154 double XY ;
00155 DWORD Pixel;
00156 INT32 LowX;
00157 INT32 LowY;
00158 };
00159
00160 inline INT32 IntegerSquare(INT32 i) { return i*i; }
00161 inline double DoubleSquare(double d) { return d*d; }
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 typedef struct
00174 {
00175 INT32 X;
00176 INT32 Y;
00177 INT32 Area;
00178 } BfxErrorRegionListItem;
00179
00180 class BfxErrorRegionList : public CCObject
00181 {
00182 CC_DECLARE_DYNCREATE(BfxErrorRegionList);
00183
00184 public:
00185
00186 BfxErrorRegionList();
00187 ~BfxErrorRegionList();
00188
00189 protected:
00190
00191 BfxErrorRegionListItem * pList;
00192 INT32 ListLength;
00193 INT32 Used;
00194
00195 INT32 CurrentRead;
00196 INT32 CurrentWrite;
00197 BOOL Sorted;
00198
00199 void Swap( BfxErrorRegionListItem * A, BfxErrorRegionListItem * B) { BfxErrorRegionListItem T;
00200 T.X=A->X;T.Y=A->Y;T.Area=A->Area;A->X=B->X;A->Y=B->Y;A->Area=B->Area;B->X=T.X;B->Y=T.Y;B->Area=T.Area;};
00201
00202
00203 public:
00204
00205 BOOL Next() {if (pList && pList[CurrentRead].Area) CurrentRead++;return TRUE;};
00206 BOOL Init(UINT32 Length);
00207 BOOL ResetRead();
00208 BOOL Empty();
00209 BOOL Insert(INT32 XCoord, INT32 YCoord, INT32 Area);
00210 BOOL Sort();
00211 BOOL IsSpace() { return (CurrentWrite<ListLength); };
00212 BOOL GetCurrent(INT32 * XCoord, INT32 * YCoord, INT32 * Area)
00213 {return ((pList) && (*XCoord=pList[CurrentRead].X,*YCoord=pList[CurrentRead].Y,*Area = pList[CurrentRead].Area));};
00214 BOOL MarkUsed() { return (pList && ((!pList[CurrentRead].Area) || (pList[CurrentRead].Area=1))); };
00215 INT32 GetSize() { return ListLength; };
00216
00217 };
00218 #endif
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 class BfxALU : public CCObject
00266 {
00267 CC_DECLARE_DYNCREATE(BfxALU);
00268
00269 public:
00270
00271 BfxALU();
00272 virtual ~BfxALU();
00273
00274 #ifndef EXCLUDE_FROM_RALPH
00275 virtual BOOL Init();
00276 virtual BOOL DeInit();
00277
00278 virtual KernelBitmap * NewBitmap(KernelBitmap *pBitmap,INT32 XAdjust=0,INT32 YAdjust=0,
00279 INT32 NewDepth=0, String_256 * pName =NULL, UINT32 ResID =0);
00280
00281 virtual BOOL SetA(KernelBitmap * pBitmap=NULL);
00282 virtual BOOL SetB(KernelBitmap *pBitmap=NULL,INT32 XOffset=0,INT32 YOffset=0,
00283 const BYTE * pTable=NULL,DWORD Style=0);
00284 virtual BOOL SetB(DWORD Colour);
00285 virtual BOOL SetT(KernelBitmap *pBitmap=NULL,INT32 XOffset=0,INT32 YOffset=0,
00286 const BYTE * pTable=NULL,DWORD Style=0);
00287 virtual BOOL SetT(DWORD Value);
00288
00289 virtual BOOL PlotB();
00290 virtual BOOL PlotBLUT(BfxALULUT * LUT);
00291
00292 virtual BOOL PartTAB();
00293 virtual BOOL PartMulTAB();
00294 virtual BOOL PartRevMulTAB();
00295 virtual BOOL AddTAB();
00296 virtual BOOL SubTAB();
00297
00298 virtual BOOL PartKAB(DWORD Value);
00299 virtual BOOL PartMulKAB(DWORD Value);
00300 virtual BOOL PartRevMulKAB(DWORD Value);
00301 virtual BOOL AddKAB(DWORD Value);
00302 virtual BOOL SubKAB(DWORD Value);
00303
00304 virtual BOOL MarkThresholdError(INT32 Value, DWORD MarkValue, DWORD ClearValue);
00305 virtual BOOL MarkColourThresholdError(INT32 Value, DWORD Colour, DWORD MarkValue, DWORD ClearValue,
00306 double * pAError, double * pBError, INT32 * pTotalPixels, INT32 * pMarkedPixels);
00307
00308 virtual BOOL MarkPositive(INT32 Value, DWORD MarkValue, DWORD ClearValue,
00309 double * pAError = NULL, double * pBError = NULL,
00310 INT32 * pTotalPixels = NULL, INT32 * pMarkedPixels = NULL);
00311 virtual BOOL MarkLargestArea(DWORD MarkValue, DWORD ClearValue, DWORD RegionValue,
00312 BOOL * FoundRegion, INT32 * InitialX, INT32 * InitialY, INT32 * Area);
00313 virtual BOOL MarkGivenArea(DWORD MarkValue, DWORD ClearValue, DWORD RegionValue,
00314 BOOL * FoundRegion, INT32 * InitialX, INT32 * InitialY, INT32 * Area);
00315 virtual BOOL GradFillPath(Path * ThePath, DWORD StartColour, DWORD EndColour,
00316 INT32 StartX, INT32 StartY, INT32 EndX, INT32 EndY,
00317 BOOL AntiAlias = FALSE, BOOL ColoursAreDWORDs = FALSE);
00318 virtual BOOL GetStatistics(Path * ThePath, KernelStatistics * pStats);
00319 virtual BOOL MarkBitByWord(DWORD BitMask, DWORD TheWord);
00320 virtual BOOL ClearBitByWord(DWORD BitMask, DWORD TheWord);
00321 virtual BOOL MarkWordByBit(DWORD BitMask, DWORD MarkValue, DWORD ClearValue);
00322 virtual BOOL BuildErrorRegionList(DWORD MarkValue, DWORD ClearValue, DWORD RegionValue,
00323 BfxErrorRegionList * pERL, INT32 MinimumArea);
00324 virtual BOOL ScanBit(DWORD BitMask, INT32 * X, INT32 * Y, INT32 *pPixel, BOOL * Found, BOOL CheckConnected=FALSE);
00325 virtual BOOL ScanThreshold(INT32 Value, INT32 * X, INT32 * Y, INT32 *pPixel, BOOL * Found, BOOL CheckConnected=FALSE);
00326
00327 virtual BOOL GetSize(KernelBitmap * pBitmap, INT32 * pXSize=NULL, INT32 * pYSize=NULL, INT32 * pDepth=NULL);
00328
00329 virtual BOOL ZeroA(DWORD FillValue = 0);
00330 virtual BOOL ByteCopyBA();
00331
00332 virtual void TestGD();
00333
00334 #ifndef WEBSTER
00335 PORTNOTE("other", "Remove accusoft effects")
00336 #ifndef EXCLUDE_FROM_XARALX
00337
00338 virtual BOOL FlipX(KernelBitmap * * ppOutput);
00339 virtual BOOL FlipY(KernelBitmap * * ppOutput);
00340 virtual BOOL Rotate90(KernelBitmap * * ppOutput);
00341 virtual BOOL Rotate180(KernelBitmap * * ppOutput);
00342 virtual BOOL Rotate270(KernelBitmap * * ppOutput);
00343
00344 virtual BOOL Resize(KernelBitmap * * ppOutput, INT32 Width, INT32 Height, BOOL LinearInterpolation);
00345
00346 virtual BOOL BrightnessContrast(KernelBitmap * * ppOutput, INT32 Brightness=0, INT32 Contrast=0, INT32 Colour=0);
00347
00348 virtual BOOL BayerMono(KernelBitmap * * ppOutput);
00349 virtual BOOL HalftoneMono(KernelBitmap * * ppOutput);
00350 virtual BOOL DiffusionMono(KernelBitmap * * ppOutput);
00351 virtual BOOL BayerColour(KernelBitmap * * ppOutput);
00352 virtual BOOL DiffusionColour(KernelBitmap * * ppOutput);
00353 virtual BOOL PopularityColour(KernelBitmap * * ppOutput);
00354 virtual BOOL MakeGreyscale(KernelBitmap * * ppOutput);
00355 #endif //XARALX
00356 #endif //WEBSTER
00357 virtual BOOL MakeGreyscale32to8(KernelBitmap * * ppOutput);
00358
00359 #endif
00360 static BOOL IsGreyscaleBitmap(KernelBitmap * pKB);
00361 static BOOL IsGreyscaleBitmap(OILBitmap * pOilBmp);
00362 #ifndef EXCLUDE_FROM_RALPH
00363 #ifndef WEBSTER
00364 PORTNOTE("other", "Remove accusoft effects")
00365 #ifndef EXCLUDE_FROM_XARALX
00366 virtual BOOL Octree (KernelBitmap * * ppOutput);
00367
00368 virtual BOOL SharpenBlur(KernelBitmap * * ppOutput, INT32 Degree, INT32 Times);
00369 #endif
00370 virtual BOOL RemoveDither(KernelBitmap * * ppOutput, INT32 Thresh, INT32 QuantCols, TraceMethod Method);
00371 #ifndef EXCLUDE_FROM_XARALX
00372 virtual BOOL SpecialEffect(KernelBitmap * * ppOutput, double * Matrix, BfxSpecialEffect Type);
00373 #endif
00374 #endif //WEBSTER
00375
00376 protected:
00377
00378 virtual BOOL DoRect();
00379 virtual BOOL UseBT(DWORD TransparencyStyle=0);
00380 virtual BOOL UseBK(DWORD TransparencyStyle,DWORD Value);
00381
00382 virtual BOOL MarkRegions(DWORD MarkValue, DWORD ClearValue,
00383 BOOL * FoundRegion, INT32 * InitialX, INT32 * InitialY, INT32 * Area,
00384 INT32 * pSize, INT32 * pHighestChain, INT32 * pWidth, DWORD * * ppA);
00385
00386 #ifndef WEBSTER
00387 PORTNOTE("other", "Remove accusoft effects")
00388 #ifndef EXCLUDE_FROM_XARALX
00389 virtual BOOL MakeAccusoftHandle(INT32 * pHandle, BOOL DoBodge = FALSE);
00390 virtual BOOL MakeKernelBitmap(INT32 Handle, KernelBitmap * * ppOutput, BOOL Make32Bits = FALSE,
00391 String_256 * pName = NULL, UINT32 ResID = 0, BOOL DoBodge = FALSE);
00392 #endif
00393 virtual BOOL AdjustBrightnessContrastColour(LPBYTE Source, LPBYTE Dest, INT32 Size, INT32 Width, INT32 Height,
00394 INT32 Brightness, INT32 Contrast, INT32 Colour, BOOL SingleChannel);
00395 #ifndef EXCLUDE_FROM_XARALX
00396 BOOL MAH_BodgeCopyBitmap(INT32 Width, INT32 Height, INT32 Depth, LPBYTE pSourceBits, LPBYTE pDestBits);
00397 BOOL MKB_BodgeCopyBitmap(INT32 Width, INT32 Height, INT32 Depth, LPBYTE pSourceBits, LPBYTE pDestBits);
00398 #endif
00399 #endif //WEBSTER
00400
00401 void ConvertScanLineToDWORD(KernelBitmap * pBitmap, INT32 Line, DWORD * pBuffer);
00402 void ConvertScanLineFromDWORD(KernelBitmap * pBitmap, INT32 Line, DWORD * pBuffer);
00403
00404 void SlowRemoveDither(BYTE * ByteLine[5], INT32 NoiseMatrix[5][5],
00405 BYTE * OutputLine, INT32 Width, INT32 Thresh, BOOL Mono);
00406
00407 KernelBitmap * A;
00408 KernelBitmap * B;
00409 KernelBitmap * T;
00410
00411 POINT BPoints[3];
00412 POINT TPoints[3];
00413
00414 COLORREF BColour;
00415 DWORD TValue;
00416
00417 const BYTE * BpTable;
00418 const BYTE * TpTable;
00419
00420 DWORD BStyle;
00421 DWORD TStyle;
00422
00423 GDrawContext * GC;
00424
00425 GMATRIX identity;
00426
00427 BOOL ResetAccusoftDibsToRuns;
00428 #endif
00429 };
00430
00431 #ifndef EXCLUDE_FROM_RALPH
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 class BfxALU;
00446
00447 class BfxALULUT : public CCObject
00448 {
00449 CC_DECLARE_DYNCREATE(BfxALULUT);
00450
00451 friend class BfxALU;
00452
00453
00454
00455
00456 public:
00457
00458 BOOL LinearABK(double PropA, double PropB, double Offset);
00459 BYTE GetLUT(UINT32 A, UINT32 B);
00460
00461 protected:
00462
00463 BYTE Data[256*256];
00464 };
00465
00466 #endif // EXCLUDE_FROM_RALPH
00467 #endif // INC_BFXALU
00468