bfxalu.h

Go to the documentation of this file.
00001 // $Id: bfxalu.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // This is the header file for the bitmap effect ALU class
00099 
00100 /*
00101 */
00102 
00103 #ifndef INC_BFXALU
00104 #define INC_BFXALU
00105 
00106 //#include "ccobject.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 class KernelBitmap;
00108 class OILBitmap;
00109 
00110 #ifndef EXCLUDE_FROM_RALPH
00111 
00112 //#include "gconsts.h" // For GMATRIX - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "tracectl.h" // for enum TraceMethod - annoying...
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 /* should be a struct but the C compiler is crap*/
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 >   class BfxErrorRegionList : public CCObject
00166 
00167     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00168     Created:    02/01/1995
00169     Purpose:    Stores error region list for tracing
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();            /* Constructor */
00187     ~BfxErrorRegionList();       /* Destructor */
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=/*assign*/1))); };
00215     INT32 GetSize() { return ListLength; };
00216 
00217 };
00218 #endif
00219 
00220 /********************************************************************************************
00221 
00222 >   class BfxALU : public CCObject
00223 
00224     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00225     Created:    12/10/1994
00226     Purpose:    Arithmetic and logic unit for bitmap effects
00227 
00228 This class implements the Bitmap Effect ALU (Arithmetic and logic unit). You can think of
00229 this as the Kernel i/f for GDraw when using bitmap effects, but that would be a bit of a
00230 narrow view. The class is there to perform fast arithmetic and logical operations on bitmaps,
00231 and at the moment, we reckon the fastest way to do that is to use GDraw.
00232 
00233 The ALU works very like a processor ALU, except each register holds a bitmap (actually a
00234 pointer to a bitmap which can cause some complications), and each operand (like Add) adds
00235 two bitmaps, rather than two integers. In fact, some registers may be set to 'pseudo bitmaps'
00236 like solid colour and linear fills, which are usefully expanded by the ALU at plot time without
00237 occupying memory.
00238 
00239 The ALU has the following registers:
00240     Name            Purpose
00241     ====            =======
00242     A (Accumulator) The accumulator is the destination register for all operands, and is the
00243                     source register for many. The accumulator can be 32 bit or 8 bpp grey
00244                     but at the moment only 32 bpp is supported. The T channel of the
00245                     accumulator is always zero (well, that's how the plot operations leave
00246                     it anyway).
00247     B (Bitmap)      A general purpose bitmap, normally used as a secondary source operand.
00248     T (Bitmap)      And 8 bit bitmap used for weigthing values on some calls.
00249 
00250 Here are some example arithmetic operands:
00251 
00252 AddpAqB A <- pA+qB
00253 AddApB  A <- A+pB
00254 SubApB  A <- A-pB
00255 InvA    A <- 255-A
00256 
00257 Here are some example load & store operations
00258 
00259 SetA(bitmap)
00260 SetB(bitmap)
00261 SetB(linear fill parameters)
00262 
00263 ********************************************************************************************/
00264 
00265 class BfxALU : public CCObject
00266 {
00267     CC_DECLARE_DYNCREATE(BfxALU);
00268 
00269     public:
00270 
00271     BfxALU();            /* Constructor */
00272     virtual ~BfxALU();       /* Destructor */
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     // Accusoft effects
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 >   class BfxALULUT : public CCObject
00435 
00436     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
00437     Created:    12/10/1994
00438     Purpose:    Lookup table
00439 
00440 This class implements the Bitmap Effect ALU (Arithmetic and logic unit) LUT (look up table).
00441 This isolates the kernel classes from th storage format of the LUT
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     //BfxALULUT(); constructors and destructors are simple
00454     //~BFXALULUT();
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 

Generated on Sat Nov 10 03:48:06 2007 for Camelot by  doxygen 1.4.4