BfxPixelOpPseudo Class Reference

#include <bfxpixop.h>

Inheritance diagram for BfxPixelOpPseudo:

BfxPixelOp CCObject SimpleCCObject BfxColourThresholdPixelOpPseudo BfxPositivePixelOpPseudo BfxThresholdPixelOpPseudo List of all members.

Public Member Functions

 BfxPixelOpPseudo ()
 Default constructor for pixel op.
virtual ~BfxPixelOpPseudo ()
 Default destructor for pixel op.
virtual BOOL Reset ()
 Resets all parameters associated with the cache.
virtual BOOL SetBitmap (KernelBitmap *pKB, DWORD theCacheStateMask, DWORD theCacheValueMask, BOOL theDefaultValue)
 Class set up to use bitmap passed in.
virtual BOOL IsInRegion (INT32 x, INT32 y)
virtual void TranslateToRGB (DWORD Colour, KernelBitmap *pKB, INT32 *R, INT32 *G, INT32 *B)
 To get the R G B values corresponding to a memory entry.
virtual DWORD ReadPixel (void *Image, INT32 p)
virtual void WritePixel (void *Image, INT32 p, DWORD Value)
virtual BOOL CheckMinimumArea (INT32 MinimumArea, INT32 InitialX, INT32 InitialY, BOOL *FoundRegion)
 Determines whether atleast (MinimumArea) pixels are within the region.

Protected Member Functions

BOOL FloodSearch (INT32 x, INT32 y, INT32 MinimumArea, INT32 FloodArray[256][2], INT32 *FloodTop)
 Recursively flood fills an area until >=MinimumArea pixels are found.

Protected Attributes

INT32 Log2BPP
INT32 XShift
INT32 XMask
INT32 BPPMask

Private Member Functions

 CC_DECLARE_DYNCREATE (BfxPixelOpPseudo)

Detailed Description

Definition at line 296 of file bfxpixop.h.


Constructor & Destructor Documentation

BfxPixelOpPseudo::BfxPixelOpPseudo  ) 
 

Default constructor for pixel op.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
None [INPUTS]
Constructs object [OUTPUTS]
Returns:
Nothing

Errors: None yet

See also:
-

Definition at line 688 of file bfxpixop.cpp.

00688                                    : BfxPixelOp()
00689 {
00690     BPP=8;
00691 }

BfxPixelOpPseudo::~BfxPixelOpPseudo  )  [virtual]
 

Default destructor for pixel op.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
None [INPUTS]
Constructs object [OUTPUTS]
Returns:
Nothing

Errors: Error3 if DeInit hasn't been called.

See also:
-

Definition at line 708 of file bfxpixop.cpp.

00709 {
00710 }


Member Function Documentation

BfxPixelOpPseudo::CC_DECLARE_DYNCREATE BfxPixelOpPseudo   )  [private]
 

BOOL BfxPixelOpPseudo::CheckMinimumArea INT32  MinimumArea,
INT32  InitialX,
INT32  InitialY,
BOOL *  FoundRegion
[virtual]
 

Determines whether atleast (MinimumArea) pixels are within the region.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/1/95
Parameters:
MinimumArea = minimum area [INPUTS]
FoundRegion set as per whether it's found a region [OUTPUTS]
Returns:
TRUE on success, FALSE (& error set) on failure

Errors: None yet Scope: Public

See also:
BfxPixelOpPseudo::CheckMinimumArea, TraceControl::FloodSearch
FoundRegion is set according the the result. The search starts at InitialX/InitialY

This call *must* be done immediately (yes, immediately) after the cache is cleared. If not you lose all your caching. Har har.

Reimplemented from BfxPixelOp.

Definition at line 1066 of file bfxpixop.cpp.

01067 {
01068     // This is a bodge currently
01069     *FoundRegion = FALSE;
01070     if (IsInRegion(InitialX, InitialY))
01071     {
01072         if (MinimumArea>BFX_PSEUDOFLOODSIZE-1) MinimumArea=BFX_PSEUDOFLOODSIZE-1;
01073         INT32 FloodArray[BFX_PSEUDOFLOODSIZE][2];
01074         INT32 FloodTop=0;
01075 
01076         if (!FloodSearch(InitialX, InitialY, MinimumArea, FloodArray, &FloodTop)) return FALSE;
01077         *FoundRegion = (FloodTop >= MinimumArea);
01078 
01079         for (INT32 n=0; n<FloodTop; n++) WriteOriginalPixel(FloodArray[n][0], FloodArray[n][1], Colour);
01080     }
01081 
01082     return TRUE;
01083 }

BOOL BfxPixelOpPseudo::FloodSearch INT32  x,
INT32  y,
INT32  MinimumArea,
INT32  FloodArray[256][2],
INT32 *  FloodTop
[protected]
 

Recursively flood fills an area until >=MinimumArea pixels are found.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/1/95
Parameters:
x = start x [INPUTS] y = start y MinimumArea = minimum area
None [OUTPUTS]
Returns:
TRUE on success, FALSE (& error set) on failure

Errors: None yet Scope: Public

See also:
BfxPixelOpPseudo::CheckMinimumArea, TraceControl::CheckMinimumArea
ONLY TO BE USED FROM CheckMinimumArea ***

Definition at line 1106 of file bfxpixop.cpp.

01108 {
01109     if (IsInRegion(x,y))
01110     {
01111         WriteOriginalPixel(x, y, Colour^1); // make it out of the region
01112         FloodArray[*FloodTop][0]=x;
01113         FloodArray[(*FloodTop)++][1]=y; // save coordinate so we can restore value later
01114         if (*FloodTop>=MinimumArea) return TRUE;
01115         if (!FloodSearch(x-1, y-1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01116         if (*FloodTop>=MinimumArea) return TRUE;
01117         if (!FloodSearch(x  , y-1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01118         if (*FloodTop>=MinimumArea) return TRUE;
01119         if (!FloodSearch(x+1, y-1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01120         if (*FloodTop>=MinimumArea) return TRUE;
01121         if (!FloodSearch(x-1, y  , MinimumArea, FloodArray, FloodTop)) return FALSE;
01122         if (*FloodTop>=MinimumArea) return TRUE;
01123         if (!FloodSearch(x+1, y  , MinimumArea, FloodArray, FloodTop)) return FALSE;
01124         if (*FloodTop>=MinimumArea) return TRUE;
01125         if (!FloodSearch(x-1, y+1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01126         if (*FloodTop>=MinimumArea) return TRUE;
01127         if (!FloodSearch(x  , y+1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01128         if (*FloodTop>=MinimumArea) return TRUE;
01129         if (!FloodSearch(x+1, y+1, MinimumArea, FloodArray, FloodTop)) return FALSE;
01130     }
01131     return TRUE;
01132 }

virtual BOOL BfxPixelOpPseudo::IsInRegion INT32  x,
INT32  y
[inline, virtual]
 

Reimplemented from BfxPixelOp.

Definition at line 309 of file bfxpixop.h.

00309                                                      {
00310         if (( (DWORD)x>=(DWORD)Width ) || ( (DWORD)y>=(DWORD)Height ) ) return DefaultValue;
00311         else return IsPixelReallyInRegion(x, y);};

virtual DWORD BfxPixelOpPseudo::ReadPixel void *  Image,
INT32  p
[inline, virtual]
 

Reimplemented from BfxPixelOp.

Definition at line 315 of file bfxpixop.h.

00316     {
00317         if ( (((DWORD)p)>=Size)||!Image)
00318         {
00319             ERROR3("Out of range BfxPixOp::ReadPixel()");
00320             return 0;
00321         }
00322         return (DWORD)(((((BYTE *) Image)[p>>XShift])>>((XMask-(p & XMask))<<Log2BPP))&BPPMask);
00323     };

BOOL BfxPixelOpPseudo::Reset void   )  [virtual]
 

Resets all parameters associated with the cache.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
None [INPUTS]
Resets all parameters associated with the cache [OUTPUTS]
Returns:
TRUE if succeeded, FALSE & error set if not

Errors: Error 2 if init hasn't been called or GDraw fails Error 3 if windows and some other Oil layer are stangely mixed... Scope: Public

See also:
-

Reimplemented from BfxPixelOp.

Definition at line 729 of file bfxpixop.cpp.

00730 {
00731     return BfxPixelOp::Reset();
00732 }

BOOL BfxPixelOpPseudo::SetBitmap KernelBitmap pKB,
DWORD  theCacheStateMask,
DWORD  theCacheValueMask,
BOOL  theDefaultValue
[virtual]
 

Class set up to use bitmap passed in.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
pKB = pointer to the bitmap [INPUTS] theCacheStateMask = bit mask used to show cache information theCacheValueMask = bit mask used to show cache value information theDefaultValue = BOOL value associated with pixels outside the bitmap
None [OUTPUTS]
Returns:
TRUE if succeeded, FALSE & error set if not

Errors: Error 2 if init hasn't been called or GDraw fails Error 3 if windows and some other Oil layer are stangely mixed... Scope: Public

See also:
-

Reimplemented from BfxPixelOp.

Definition at line 758 of file bfxpixop.cpp.

00760 {
00761     Base = NULL;
00762     ERROR2IF( ((!pKB) || (pKB->ActualBitmap==NULL)) ,FALSE,"BfxALU can't find OIL bitmap");
00763     ERROR3IF( (!(pKB->ActualBitmap->IsKindOf(CC_RUNTIME_CLASS(CWxBitmap)) )),"BfxALU Oil layer inconsistency");
00764 
00765     BITMAPINFOHEADER * pBMI=&(((CWxBitmap *)(pKB->ActualBitmap))->BMInfo->bmiHeader);
00766 
00767     BPP=pBMI->biBitCount;
00768     ERROR2IF(BPP>8, FALSE,"Pseudo colour BMP not pseudo colour");
00769     switch (BPP)
00770     {
00771         case 1 : Log2BPP=0; break;
00772         case 2 : Log2BPP=1; break;
00773         case 4 : Log2BPP=2; break;
00774         case 8 : Log2BPP=3; break;
00775         default:
00776         ERROR2(FALSE, "Invalid BPP field");
00777     }
00778 
00779     if (!BfxPixelOp::SetBitmap(pKB, theCacheStateMask,theCacheValueMask, theDefaultValue)) return FALSE;
00780 
00781     BPPMask = (BPP==32)?0xFFFFFFFF:(1<<BPP)-1;
00782     XShift = 3-Log2BPP;
00783     XMask = (1<<XShift)-1;
00784     Size = (pBMI->biSizeImage<<3)>>Log2BPP;
00785 
00786     return TRUE;
00787 }

void BfxPixelOpPseudo::TranslateToRGB DWORD  Colour,
KernelBitmap pKB,
INT32 *  R,
INT32 *  G,
INT32 *  B
[virtual]
 

To get the R G B values corresponding to a memory entry.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Parameters:
Colour = the colour [INPUTS]
R,G,B = rd, green, blue components [OUTPUTS]
Returns:
None

Errors: None Scope: Public

See also:
BfxPixelOpPseudo::IsInRegion()

Reimplemented from BfxPixelOp.

Definition at line 1016 of file bfxpixop.cpp.

01018 {
01019     RGBQUAD Col;
01020 
01021     if ((!pKB) || (pKB->ActualBitmap==NULL))
01022     {
01023         ERROR3( "BfxALU can't find OIL bitmap");
01024         return;
01025     }
01026     ERROR3IF( (!(pKB->ActualBitmap->IsKindOf(CC_RUNTIME_CLASS(CWxBitmap)) )),"BfxALU Oil layer inconsistency");
01027 
01028     BITMAPINFOHEADER * pBMI=&(((CWxBitmap *)(pKB->ActualBitmap))->BMInfo->bmiHeader);
01029 
01030     if ( Colour >= pBMI->biClrUsed )
01031     {
01032         ERROR3("Too large palette entry");
01033         *R=*G=*B=0;
01034         return;
01035     }
01036 
01037     Col = ((RGBQUAD *)(pBMI+1/*pointer arith*/))[Colour];   
01038     
01039     *R = Col.rgbRed;
01040     *G = Col.rgbGreen;
01041     *B = Col.rgbBlue;
01042     return;
01043 };

virtual void BfxPixelOpPseudo::WritePixel void *  Image,
INT32  p,
DWORD  Value
[inline, virtual]
 

Reimplemented from BfxPixelOp.

Definition at line 325 of file bfxpixop.h.

00326     {
00327         if ( (((DWORD)p)>=Size)||!Image)
00328         {
00329             ERROR3("Out of range BfxPixOp::ReadPixel()");
00330             return;
00331         }
00332         BYTE * thebyte = &(((BYTE *) Image)[p>>XShift]);
00333         INT32 shift = ((XMask-(p & XMask))<<Log2BPP);
00334         *thebyte = (BYTE)(((*thebyte) & ~(BPPMask<<shift)) | ((Value & BPPMask)<<shift));
00335         return;
00336     };


Member Data Documentation

INT32 BfxPixelOpPseudo::BPPMask [protected]
 

Definition at line 349 of file bfxpixop.h.

INT32 BfxPixelOpPseudo::Log2BPP [protected]
 

Definition at line 346 of file bfxpixop.h.

INT32 BfxPixelOpPseudo::XMask [protected]
 

Definition at line 348 of file bfxpixop.h.

INT32 BfxPixelOpPseudo::XShift [protected]
 

Definition at line 347 of file bfxpixop.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:11 2007 for Camelot by  doxygen 1.4.4