#include <maskedrr.h>
Inheritance diagram for MaskedRenderRegion:
Public Member Functions | |
MaskedRenderRegion (DocRect, Matrix, FIXED16, double) | |
Constructor. Sends everything on to the base class. INT32 dpi changed to FIXED16 dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using. | |
~MaskedRenderRegion () | |
Default destructor. | |
BOOL | StartRender () |
Starts the render region up. This version just calls the base class and allocates a couple of attributes used during the rendering. | |
void | SetHostCaps (RRCaps *pCaps) |
Tells the mask region what attributes are considered complex. | |
virtual void | DrawPathToOutputDevice (Path *PathToRender, PathShape shapePath=PATHSHAPE_PATH) |
Renders the path into the mask. It makes sure that all the attributes are set up correctly first though. | |
virtual void | DrawRect (DocRect *RectToRender) |
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function. | |
virtual void | DrawLine (const DocCoord &StartPoint, const DocCoord &EndPoint) |
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function. | |
virtual void | DrawPixel (const DocCoord &Point) |
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function. | |
virtual void | DrawBitmap (const DocCoord &Point, KernelBitmap *pBitmap) |
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function. | |
virtual void | DrawBitmap (const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID=NULL) |
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function. | |
virtual BOOL | DrawTransformedBitmap (NodeBitmap *pNodeBitmap) |
virtual void | DrawDragRect (DocRect *RectToRender) |
None - Does nothing. | |
virtual void | DrawBlob (DocCoord p, BlobType type) |
None - Does nothing. | |
virtual void | DrawCross (const DocCoord &Point, const UINT32 Size) |
None - Does nothing. | |
virtual void | DrawBitmapBlob (const DocCoord &Point, KernelBitmap *BlobShape) |
None - Does nothing. | |
virtual void | DrawBitmapBlob (const DocCoord &Point, ResourceID resID) |
None - Does nothing. | |
BOOL | SpreadMask () |
Spreads the mask out by a pixel. This allows us to make the area that is blitted slightly bigger to cover up any differences between the device resolution and the bitmap resolution. This function will grow the mask above, below, to the left and right by a single pixel. If this is not enough, call this function more than once. | |
INT32 | FindCoverage (BOOL AnyCoverageReturns100=FALSE) |
Finds out how much of the mask has been set. | |
INT32 | FindMaskDpi () |
This function is used to find out the DPI that the region was created at. This is important as the device it is displaying to may have a different dpi and the difference has to be compensated for. Returns a INT32 form of the dpi As most printing and masking related items only require non-fractional dpis then this should not be a problem. So return a rounded up form of the stored double form. | |
void | GetFirstMaskRegion (MaskRegion *pMaskInfo) |
This function is used to find out the DPI that the region was created at. This is important as the device it is displaying to may have a different dpi and the difference has to be compensated for. Returns the new double form of the dpiThis function finds the first scan line section in the mask that indicates pixels need to be set. When it finds the next section it fills in the info about it in pMaskInfo and returns. If there are no regions to be found in the mask then the Length member of pMaskInfo will be set to zero. This is your clue that there are no scan line sections to process. | |
void | GetNextMaskRegion (MaskRegion *pMaskInfo) |
This function finds the next scan line section in the mask that indicates pixels need to be set. It uses the info in the pMaskInfo param to work out where to start looking from. When it finds the next section, which could be on the same scan line as the present one, it fills in the info about it in pMaskInfo and returns. If there are no more regions to be found in the mask then the Length member of pMaskInfo will be set to zero. This is your clue that there are no more scan line sections to process. | |
virtual void | SetOffscreen (OffscreenAttrValue *) |
Create a new bitmap into which, the subtree rooted at this attributes parent, will be rendered. Then call base version to push the current OffscreenAttr onto the context stack. | |
virtual void | RestoreOffscreen (OffscreenAttrValue *) |
Protected Member Functions | |
void | ScanMaskFrom (MaskRegion *pMaskInfo) |
Searchs the mask for a section that means we will have to blit something. The starting position of the section and the length of the section are put into pMaskInfo and returned. pMaskInfo->Length will be set to zero if there are no more sections in the mask. | |
void | SetNextShapeColour (DocColour &RequiredCol) |
Sets all the attributes up so that we can render into our mask. It will boil everything down to a flat fill and stroke ready to be rendered into the mask. The colour passed in will probably be Black or White, but I left it open in case I thought of some other use for this. | |
Protected Attributes | |
DocColour | Black |
DocColour | White |
RRCaps | HostCaps |
FlatTranspFillAttribute * | pFillAttr |
StrokeTranspAttribute * | pStrokeAttr |
Static Protected Attributes | |
static INT32 | BitCountTable [256] |
Definition at line 155 of file maskedrr.h.
|
Constructor. Sends everything on to the base class. INT32 dpi changed to FIXED16 dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.
Definition at line 197 of file maskedrr.cpp. 00199 : GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 1, dpi) 00200 { 00201 // Some attrs we use. NULL by default 00202 pFillAttr = NULL; 00203 pStrokeAttr = NULL; 00204 Black = DocColour(0,0,0); 00205 White = DocColour(255,255,255); 00206 }
|
|
Default destructor.
Definition at line 219 of file maskedrr.cpp. 00220 { 00221 // Kill the fill attr 00222 if (pFillAttr!=NULL) 00223 { 00224 delete pFillAttr; 00225 pFillAttr = NULL; 00226 } 00227 00228 // kill the stroke attr 00229 if (pStrokeAttr!=NULL) 00230 { 00231 delete pStrokeAttr; 00232 pStrokeAttr = NULL; 00233 } 00234 }
|
|
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 506 of file maskedrr.cpp. 00507 { 00508 // Save the context 00509 SaveContext(); 00510 00511 // Does this shape make use of complex things 00512 if (TestForComplexShape(&HostCaps)) 00513 SetNextShapeColour(Black); 00514 else 00515 SetNextShapeColour(White); 00516 00517 // Draw the path 00518 GRenderBitmap::DrawBitmap(Point, BitmapID, ToolID); 00519 00520 // restore the context 00521 RestoreContext(); 00522 }
|
|
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 471 of file maskedrr.cpp. 00472 { 00473 // Save the context 00474 SaveContext(); 00475 00476 // Does this shape make use of complex things 00477 if (TestForComplexShape(&HostCaps)) 00478 SetNextShapeColour(Black); 00479 else 00480 SetNextShapeColour(White); 00481 00482 // Draw the path 00483 GRenderBitmap::DrawBitmap(Point, pBitmap); 00484 00485 // restore the context 00486 RestoreContext(); 00487 }
|
|
None - Does nothing.
Reimplemented from GRenderRegion. Definition at line 682 of file maskedrr.cpp.
|
|
None - Does nothing.
Reimplemented from GRenderRegion. Definition at line 663 of file maskedrr.cpp.
|
|
None - Does nothing.
Reimplemented from GRenderRegion. Definition at line 628 of file maskedrr.cpp.
|
|
None - Does nothing.
Reimplemented from GRenderRegion. Definition at line 645 of file maskedrr.cpp.
|
|
None - Does nothing.
Reimplemented from GRenderRegion. Definition at line 611 of file maskedrr.cpp.
|
|
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 406 of file maskedrr.cpp. 00407 { 00408 // Save the context 00409 SaveContext(); 00410 00411 // Does this shape make use of complex things 00412 if (TestForComplexShape(&HostCaps)) 00413 SetNextShapeColour(Black); 00414 else 00415 SetNextShapeColour(White); 00416 00417 // Draw the path 00418 GRenderBitmap::DrawLine(StartPoint, EndPoint); 00419 00420 // restore the context 00421 RestoreContext(); 00422 }
|
|
Renders the path into the mask. It makes sure that all the attributes are set up correctly first though.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 313 of file maskedrr.cpp. 00314 { 00315 // Save the context 00316 SaveContext(); 00317 00318 BOOL RenderFill = FALSE; 00319 00320 // Get the current fill attr 00321 FillGeometryAttribute* pFillAttr = (FillGeometryAttribute*) CurrentAttrs[ATTR_FILLGEOMETRY].pAttr; 00322 00323 if (pFillAttr->GetBitmap() != NULL && pFillAttr->GetBitmap()->GetBPP() <= 8) 00324 { 00325 INT32 TranspIndex; 00326 00327 // If it's a masked bitmap fill, then we'll need to actually render it 00328 // (but we'll force all the non-masked pixels to be rendered black) 00329 if (pFillAttr->GetBitmap()->GetTransparencyIndex(&TranspIndex)) 00330 RenderFill = TRUE; 00331 } 00332 00333 if (RenderFill) 00334 { 00335 BOOL OldVMState = RenderFlags.VeryMono; 00336 RenderFlags.VeryMono = TRUE; // Forces non-masked pixels to be plotted black 00337 00338 // Draw the path, with the bitmap fill 00339 GRenderBitmap::DrawPathToOutputDevice(pPath); 00340 00341 RenderFlags.VeryMono = OldVMState; 00342 } 00343 else 00344 { 00345 // Does this shape make use of complex things 00346 if (TestForComplexShape(&HostCaps)) 00347 SetNextShapeColour(Black); 00348 else 00349 SetNextShapeColour(White); 00350 00351 // Draw the path 00352 GRenderBitmap::DrawPathToOutputDevice(pPath); 00353 } 00354 00355 // restore the context 00356 RestoreContext(); 00357 }
|
|
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 438 of file maskedrr.cpp. 00439 { 00440 // Save the context 00441 SaveContext(); 00442 00443 // Does this shape make use of complex things 00444 if (TestForComplexShape(&HostCaps)) 00445 SetNextShapeColour(Black); 00446 else 00447 SetNextShapeColour(White); 00448 00449 // Draw the path 00450 GRenderBitmap::DrawPixel(Point); 00451 00452 // restore the context 00453 RestoreContext(); 00454 }
|
|
This function will examine the attributes etc to see if this represents a simple or compex shape. It will set up the attributes according to the result of this and then call the base class version of the function.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 373 of file maskedrr.cpp. 00374 { 00375 // Save the context 00376 SaveContext(); 00377 00378 // Does this shape make use of complex things 00379 if (TestForComplexShape(&HostCaps)) 00380 SetNextShapeColour(Black); 00381 else 00382 SetNextShapeColour(White); 00383 00384 // Draw the path 00385 GRenderBitmap::DrawRect(pRectToRender); 00386 00387 // restore the context 00388 RestoreContext(); 00389 }
|
|
Reimplemented from RenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 524 of file maskedrr.cpp. 00525 { 00526 // Save the context 00527 SaveContext(); 00528 00529 // Work out if we can do this bitmap directly 00530 BOOL CanDoBitmap = FALSE; 00531 00532 // Does this shape make use of complex things 00533 if (!(TestForComplexShape(&HostCaps) || pNodeBitmap->NeedsTransparency())) 00534 { 00535 // See what kind of bitmaps this render region can do 00536 if (HostCaps.ArbitraryBitmaps) 00537 { 00538 // We can do anything... 00539 CanDoBitmap = TRUE; 00540 } 00541 else 00542 { 00543 if (HostCaps.SimpleBitmaps) 00544 { 00545 // Check that the bitmap area is rectangular, and is perpendicular to 00546 // the x and y axes. 00547 if (pNodeBitmap->HasSimpleOrientation(this)) 00548 { 00549 // Yes - simple scaling - the render region can do this. 00550 CanDoBitmap = TRUE; 00551 } 00552 } 00553 } 00554 } 00555 00556 // Here we set up reasonable attributes - we want to fill the bitmap 00557 // path but not stroke it. NB. This is very important - do not remove 00558 // otherwise the mask will be wrong! 00559 DocColour colorBlack( COLOUR_BLACK ); 00560 SetFillColour( colorBlack ); 00561 DocColour colorNone( COLOUR_NONE ); 00562 SetLineColour( colorNone ); 00563 00564 if (CanDoBitmap) 00565 { 00566 SetNextShapeColour(White); 00567 00568 // Draw the path (that represents the bitmap object) 00569 GRenderBitmap::DrawPathToOutputDevice(&pNodeBitmap->InkPath); 00570 } 00571 else 00572 { 00573 if (pNodeBitmap->NeedsTransparency()) 00574 { 00575 // It's a masked bitmap, so we'll need to actually render the non-masked 00576 // pixels as black 00577 BOOL OldVMState = RenderFlags.VeryMono; 00578 RenderFlags.VeryMono = TRUE; // Forces non-masked pixels to be plotted black 00579 00580 // Call base class to plot the bitmap 00581 RenderRegion::DrawTransformedBitmap(pNodeBitmap); 00582 00583 RenderFlags.VeryMono = OldVMState; 00584 } 00585 else 00586 { 00587 SetNextShapeColour(Black); 00588 00589 // Draw the path (that represents the bitmap object) 00590 GRenderBitmap::DrawPathToOutputDevice(&pNodeBitmap->InkPath); 00591 } 00592 } 00593 00594 // restore the context 00595 RestoreContext(); 00596 00597 return TRUE; 00598 }
|
|
Finds out how much of the mask has been set.
Definition at line 926 of file maskedrr.cpp. 00927 { 00928 INT32 TotalPixels = 0; 00929 INT32 TotalClearPixels = 0; 00930 00931 if (pBits!=NULL && pBitmapInfo!=NULL) 00932 { 00933 // Get the scan line size in bytes 00934 const INT32 ScanLineByteSize = (pBitmapInfo->bmiHeader.biWidth+7)/8; 00935 00936 // Round it up to the nearest word boundary. Note, this is still a count of bytes 00937 const INT32 ScanLineWordSize = ((ScanLineByteSize+3)/4)*4; 00938 00939 // Work out how many padding pixels (bits) are on the end of the scanline 00940 const INT32 EndPixels = 8- ((ScanLineByteSize*8) - pBitmapInfo->bmiHeader.biWidth); 00941 00942 // The last byte of each scanline may not use all its pixels, so we build a mask, 00943 // which is used to discount padding pixels from consideration 00944 BYTE Mask = 0x0; 00945 { 00946 BYTE Bit = 0x80; 00947 for (INT32 i=0; i<EndPixels; i++) 00948 Mask |= Bit>>i; 00949 } 00950 00951 00952 // Start looping through all the scan lines in the mask 00953 LPBYTE CurrentByte = NULL; 00954 for (INT32 i=0; i<pBitmapInfo->bmiHeader.biHeight; i++) 00955 { 00956 // point CurrentByte at the start of the next scan line 00957 CurrentByte = pBits + (i*ScanLineWordSize); 00958 00959 // Count this scan line of pixels 00960 TotalPixels += pBitmapInfo->bmiHeader.biWidth; 00961 00962 // Go along the scan line, counting pixels 00963 for (INT32 j=0; j<ScanLineByteSize-1; j++) 00964 { 00965 // look up the current byte 00966 TotalClearPixels += BitCountTable[*CurrentByte]; 00967 00968 // Move to the next byte 00969 CurrentByte ++; 00970 } 00971 00972 BYTE EndByte = *CurrentByte & Mask; 00973 TotalClearPixels += BitCountTable[EndByte]; 00974 00975 // If we just want to know if the entire mask is clear, then check if we found 00976 // any non-masked pixels at all in this scanline - if so, return immediately. 00977 if (AnyCoverageReturns100 && TotalClearPixels != TotalPixels) 00978 return(100); 00979 } 00980 } 00981 00982 // The mask was empty or missing 00983 if ((TotalClearPixels==TotalPixels) || (TotalPixels==0)) 00984 { 00985 TRACEUSER( "Rik", _T("Coverage = 0\n")); 00986 return 0; 00987 } 00988 00989 // Every pixel was set 00990 if (TotalClearPixels==0) 00991 { 00992 TRACEUSER( "Rik", _T("Coverage = 100\n")); 00993 return 100; 00994 } 00995 00996 // Work out the result 00997 INT32 Result = 100 - ((TotalClearPixels*100) / TotalPixels); 00998 00999 // Rounding errors could give this misleading result 01000 if (Result<=0) 01001 Result = 1; 01002 01003 // and this one, so change them 01004 if (Result>=100) 01005 Result = 99; 01006 01007 // Tell them what percentage of pixels were set 01008 TRACEUSER( "Rik", _T("Coverage = %ld\n"), Result); 01009 return Result; 01010 }
|
|
This function is used to find out the DPI that the region was created at. This is important as the device it is displaying to may have a different dpi and the difference has to be compensated for. Returns a INT32 form of the dpi As most printing and masking related items only require non-fractional dpis then this should not be a problem. So return a rounded up form of the stored double form.
Definition at line 1031 of file maskedrr.cpp. 01032 { 01033 // tell them about the dpi 01034 // Need to return a rounded form of the stored double dpi 01035 return (INT32)(PixelsPerInch + 0.5); 01036 }
|
|
This function is used to find out the DPI that the region was created at. This is important as the device it is displaying to may have a different dpi and the difference has to be compensated for. Returns the new double form of the dpiThis function finds the first scan line section in the mask that indicates pixels need to be set. When it finds the next section it fills in the info about it in pMaskInfo and returns. If there are no regions to be found in the mask then the Length member of pMaskInfo will be set to zero. This is your clue that there are no scan line sections to process.
Definition at line 1076 of file maskedrr.cpp. 01077 { 01078 // Set up the starting conditions 01079 pMaskInfo->x = 0; 01080 pMaskInfo->y = 0; 01081 pMaskInfo->Length = 0; 01082 01083 // start looking for a bit we have to blit 01084 ScanMaskFrom(pMaskInfo); 01085 }
|
|
This function finds the next scan line section in the mask that indicates pixels need to be set. It uses the info in the pMaskInfo param to work out where to start looking from. When it finds the next section, which could be on the same scan line as the present one, it fills in the info about it in pMaskInfo and returns. If there are no more regions to be found in the mask then the Length member of pMaskInfo will be set to zero. This is your clue that there are no more scan line sections to process.
Definition at line 1110 of file maskedrr.cpp. 01111 { 01112 // Find the end of the last scan section 01113 // Move to the end of the last region 01114 pMaskInfo->x += pMaskInfo->Length; 01115 01116 // are we at the end of the scan line 01117 if (pMaskInfo->x >= pBitmapInfo->bmiHeader.biWidth) 01118 { 01119 pMaskInfo->x = 0; 01120 pMaskInfo->y++; 01121 } 01122 01123 // Reset the length to zero 01124 pMaskInfo->Length = 0; 01125 01126 // start looking for a bit we have to blit 01127 ScanMaskFrom(pMaskInfo); 01128 }
|
|
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 203 of file maskedrr.h.
|
|
Searchs the mask for a section that means we will have to blit something. The starting position of the section and the length of the section are put into pMaskInfo and returned. pMaskInfo->Length will be set to zero if there are no more sections in the mask.
Definition at line 1147 of file maskedrr.cpp. 01148 { 01149 // Assume we will find no more scan sections 01150 pMaskInfo->Length = 0; 01151 01152 // get a mask to look along the bits in the mask 01153 INT32 Mask = 0x80; 01154 INT32 XStartPos = pMaskInfo->x; 01155 INT32 YStartPos = pMaskInfo->y; 01156 01157 // Set the mask up correctly, as the X starting pos may not be at the start of a byte 01158 if (XStartPos!=0) 01159 { 01160 // Go through the byte, setting the bits back to 1 as needed 01161 INT32 PixelNum = (XStartPos/8) * 8; 01162 while (PixelNum < XStartPos) 01163 { 01164 // Shift the bit along 01165 Mask = Mask>>1; 01166 01167 // Count the pixel 01168 PixelNum++; 01169 } 01170 } 01171 01172 // Find out how many bytes in a scan line 01173 INT32 ScanLineSize = (pBitmapInfo->bmiHeader.biWidth+7)/8; 01174 ScanLineSize = (ScanLineSize+3)&~3; 01175 01176 // We start out looking for the start of a region 01177 BOOL LookingForStart = TRUE; 01178 01179 // a pointer to the byte we are dealing with 01180 LPBYTE pByte = NULL; 01181 01182 // try and find the start of the first region 01183 for (INT32 j=YStartPos; j<pBitmapInfo->bmiHeader.biHeight; j++) 01184 { 01185 // Get the byte we are interested in 01186 pByte = pBits + (j*ScanLineSize) + (XStartPos/8); 01187 01188 // start going accross the scan line 01189 for (INT32 i=XStartPos; i<pBitmapInfo->bmiHeader.biWidth; i++) 01190 { 01191 // Find out what this bit is (1 or 0) 01192 INT32 ThisBit = (*pByte) & Mask; 01193 01194 // what are we looking for - the start or the end of a region. 01195 if (LookingForStart) 01196 { 01197 if (ThisBit == 0) 01198 { 01199 // Set the start position in the mask region 01200 pMaskInfo->x = i; 01201 pMaskInfo->y = j; 01202 01203 // This bit could be all there is of a 1 pixel wide region 01204 pMaskInfo->Length = 1; 01205 01206 // we are no longer looking for the start of the region 01207 LookingForStart = FALSE; 01208 } 01209 } 01210 else 01211 { 01212 // We are looking for the end of the region 01213 if (ThisBit!=0) 01214 { 01215 // we have reached the end of the region 01216 return; 01217 } 01218 else 01219 { 01220 // we are still in the region, so count the pixel 01221 pMaskInfo->Length++; 01222 } 01223 } 01224 01225 // Move the mask bit along to the next pixel 01226 Mask = Mask>>1; 01227 01228 // if we have exhasuted this byte, go on to the next one and reset the mask 01229 if (Mask==0) 01230 { 01231 Mask = 0x80; 01232 pByte++; 01233 } 01234 } 01235 01236 // if we have found part of a region at the end of the scan line, return it 01237 if (pMaskInfo->Length>0) 01238 return; 01239 01240 // Start the next scan line from the beginning 01241 XStartPos = 0; 01242 Mask = 0x80; 01243 } 01244 }
|
|
Tells the mask region what attributes are considered complex.
Definition at line 293 of file maskedrr.cpp. 00294 { 00295 // Make a copy of the host regions caps 00296 HostCaps = *pCaps; 00297 }
|
|
Sets all the attributes up so that we can render into our mask. It will boil everything down to a flat fill and stroke ready to be rendered into the mask. The colour passed in will probably be Black or White, but I left it open in case I thought of some other use for this.
Definition at line 704 of file maskedrr.cpp. 00705 { 00706 // Find out about the fill attr 00707 ColourFillAttribute* pColFillAttr = (ColourFillAttribute*) CurrentAttrs[ATTR_FILLGEOMETRY].pAttr; 00708 if ((pColFillAttr!=NULL) && (pColFillAttr->IS_KIND_OF(GradFillAttribute))) 00709 { 00710 // This is a grad fill, so just set the colour as required 00711 SetFillColour(RequiredCol); 00712 } 00713 else 00714 { 00715 // Is there a fill colour of any kind 00716 DocColour MyFillColour = RR_FILLCOLOUR(); 00717 00718 // See if it is 'no colour' 00719 if (!MyFillColour.IsTransparent()) 00720 { 00721 // Nope, its a real colour alright, so we had better set the fill colour 00722 SetFillColour(RequiredCol); 00723 } 00724 } 00725 00726 // Find out about the line colour 00727 DocColour MyStrokeColour = RR_STROKECOLOUR(); 00728 00729 // See if it is 'no colour' 00730 if (!MyStrokeColour.IsTransparent()) 00731 { 00732 // Nope, its a real colour alright, so we had better set the fill colour 00733 SetLineColour(RequiredCol); 00734 } 00735 00736 // Set Fill transp to none 00737 if (pFillAttr!=NULL) 00738 RenderRegion::SetTranspFillGeometry(pFillAttr, FALSE); 00739 00740 // Set the stroke transp to none 00741 if (pStrokeAttr!=NULL) 00742 RenderRegion::SetLineTransp(pStrokeAttr, FALSE); 00743 }
|
|
Create a new bitmap into which, the subtree rooted at this attributes parent, will be rendered. Then call base version to push the current OffscreenAttr onto the context stack. Following only used by GRenderRegion version ** info pointer to bmp info struct which we will setup. bits pointer to bitmap bits which we'll setup.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 200 of file maskedrr.h.
|
|
Spreads the mask out by a pixel. This allows us to make the area that is blitted slightly bigger to cover up any differences between the device resolution and the bitmap resolution. This function will grow the mask above, below, to the left and right by a single pixel. If this is not enough, call this function more than once.
Definition at line 763 of file maskedrr.cpp. 00764 { 00765 // If there is a bitmap 00766 if (pBits!=NULL && pBitmapInfo!=NULL) 00767 { 00768 // Get the scan line size in bytes 00769 INT32 ScanLineByteSize = (pBitmapInfo->bmiHeader.biWidth+7)/8; 00770 00771 // Round it up to the nearest word boundary. Note, this is still a count of bytes 00772 INT32 ScanLineWordSize = ((ScanLineByteSize+3)/4)*4; 00773 00774 // Start looping through all the scan lines in the mask, 00775 // going from top to bottom, moving set pixels up 00776 LPBYTE CurrentByte = NULL; 00777 LPBYTE ByteAbove = NULL; 00778 INT32 i; 00779 for (i=1; i<pBitmapInfo->bmiHeader.biHeight; i++) 00780 { 00781 // point CurrentByte at the start of the next scan line 00782 CurrentByte = pBits + (i*ScanLineWordSize); 00783 ByteAbove = pBits + ((i-1)*ScanLineWordSize); 00784 00785 // Go along the scan line 00786 BOOL SetHighBit = FALSE; 00787 for (INT32 j=0; j<ScanLineByteSize; j++) 00788 { 00789 // Try and set the leading pixel on the current byte 00790 BYTE Mask = 0x01; 00791 BYTE Current = BYTE(~(*CurrentByte)); 00792 00793 // Loop though the mask 00794 BOOL Found = FALSE; 00795 while (Mask!=0) 00796 { 00797 // See if we have found the least sig. pixel yet 00798 if ((Mask & Current) != 0) 00799 { 00800 Found = TRUE; 00801 break; 00802 } 00803 00804 // Move the mask along a bit 00805 Mask = Mask << 1; 00806 } 00807 00808 // Set the high bit if needed 00809 if (SetHighBit) 00810 { 00811 Current = Current | 0x80; 00812 SetHighBit = FALSE; 00813 } 00814 00815 // If we found a bit in this byte, set the bit next to the least sig bit 00816 if (Found) 00817 { 00818 if (Mask==0x01) 00819 SetHighBit = TRUE; 00820 else 00821 Current = Current | (Mask>>1); 00822 } 00823 00824 // Or this byte with the one in the scan line above 00825 BYTE Result = BYTE(~(*ByteAbove)) | Current; 00826 *ByteAbove = BYTE(~Result); 00827 00828 // Move to the next byte 00829 CurrentByte++; 00830 ByteAbove++; 00831 } 00832 } 00833 00834 // Start looping through all the scan lines in the mask, 00835 // going from bottom to top, moving set pixels down 00836 CurrentByte = NULL; 00837 LPBYTE ByteBelow = NULL; 00838 for (i=pBitmapInfo->bmiHeader.biHeight-2; i>=0; i--) 00839 { 00840 // point CurrentByte at the start of the next scan line 00841 CurrentByte = pBits + (i*ScanLineWordSize) + ScanLineByteSize; 00842 ByteBelow = pBits + ((i+1)*ScanLineWordSize) + ScanLineByteSize; 00843 00844 // Go along the scan line 00845 BOOL SetLowBit = FALSE; 00846 for (INT32 j=ScanLineByteSize-1; j>=0; j--) 00847 { 00848 // Try and set the leading pixel on the current byte 00849 BYTE Mask = 0x80; 00850 BYTE Current = BYTE(~(*CurrentByte)); 00851 00852 // loop though the mask 00853 BOOL Found = FALSE; 00854 while (Mask!=0) 00855 { 00856 // See if we have found the least sig. pixel yet 00857 if ((Mask & Current) != 0) 00858 { 00859 Found = TRUE; 00860 break; 00861 } 00862 00863 // Move the mask along a bit 00864 Mask = Mask >> 1; 00865 } 00866 00867 // Set the low bit if needed 00868 if (SetLowBit) 00869 { 00870 Current = Current | 0x01; 00871 SetLowBit = FALSE; 00872 } 00873 00874 // If we found a bit in this byte, set the bit next to the most sig bit 00875 if (Found) 00876 { 00877 if (Mask==0x80) 00878 SetLowBit = TRUE; 00879 else 00880 Current = Current | (Mask<<1); 00881 } 00882 00883 // Or this byte with the one in the scan line below 00884 BYTE Result = BYTE(~(*ByteBelow)) | Current; 00885 *ByteBelow = BYTE(~Result); 00886 00887 // Move to the next byte 00888 CurrentByte--; 00889 ByteBelow--; 00890 } 00891 } 00892 } 00893 00894 return TRUE; 00895 }
|
|
Starts the render region up. This version just calls the base class and allocates a couple of attributes used during the rendering.
Reimplemented from GRenderBitmap. Definition at line 249 of file maskedrr.cpp. 00250 { 00251 // Call the base class 00252 if (!GRenderBitmap::StartRender()) 00253 return FALSE; 00254 00255 // If we got a bitmap, then clear it 00256 if (pBits!=NULL && pBitmapInfo!=NULL) 00257 { 00258 // Find out how many bytes there are to look at 00259 INT32 TotalBytes = pBitmapInfo->bmiHeader.biSizeImage; 00260 00261 // clear it all out - a Set pixels is transparent, an Unset pixel is not 00262 memset(pBits, 0xFF, TotalBytes); 00263 } 00264 00265 // Do our own thing - We need some attrs 00266 if (pFillAttr==NULL) 00267 pFillAttr = new FlatTranspFillAttribute(0); 00268 00269 if (pStrokeAttr==NULL) 00270 pStrokeAttr = new StrokeTranspAttribute(0); 00271 00272 // See if we got the ram we wanted 00273 if ((pFillAttr==NULL) || (pStrokeAttr==NULL)) 00274 return FALSE; 00275 00276 // if we get here, everything has worked 00277 return TRUE; 00278 }
|
|
Definition at line 227 of file maskedrr.h. |
|
Definition at line 215 of file maskedrr.h. |
|
Definition at line 221 of file maskedrr.h. |
|
Definition at line 224 of file maskedrr.h. |
|
Definition at line 225 of file maskedrr.h. |
|
Definition at line 216 of file maskedrr.h. |