#include <bfxpixop.h>
Inheritance diagram for BfxPixelOpPseudo:
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) |
Definition at line 296 of file bfxpixop.h.
|
Default constructor for pixel op.
Definition at line 688 of file bfxpixop.cpp. 00688 : BfxPixelOp() 00689 { 00690 BPP=8; 00691 }
|
|
Default destructor for pixel op.
Definition at line 708 of file bfxpixop.cpp.
|
|
|
|
Determines whether atleast (MinimumArea) pixels are within the region.
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 }
|
|
Recursively flood fills an area until >=MinimumArea pixels are found.
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 }
|
|
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);};
|
|
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 };
|
|
Resets all parameters associated with the cache.
Reimplemented from BfxPixelOp. Definition at line 729 of file bfxpixop.cpp. 00730 { 00731 return BfxPixelOp::Reset(); 00732 }
|
|
Class set up to use bitmap passed in.
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 }
|
|
To get the R G B values corresponding to a memory entry.
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 };
|
|
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 };
|
|
Definition at line 349 of file bfxpixop.h. |
|
Definition at line 346 of file bfxpixop.h. |
|
Definition at line 348 of file bfxpixop.h. |
|
Definition at line 347 of file bfxpixop.h. |