#include <grndclik.h>
Inheritance diagram for GRenderClickColour:
Public Member Functions | |
GRenderClickColour (DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi) | |
Constructor. Most important jobs are to set the VeryMono flag to FALSE, and to set m_DoCompression = TRUE to ensure correct handling of transparencies. | |
~GRenderClickColour () | |
Destructor. Simple cleanup, which involves calling our base classes. | |
virtual void | DebugMe (INT32 Stretch) |
Dumps the current bitmap onto the current view window, so we can see what is going on. Do not call directly, use OSRenderBitmap::DebugMe. | |
Pixel32bpp | GetCentrePixel32BPP () |
This sexy little function is what makes my custom colour picker control read the TRUE 32-bit document colour. | |
Pixel32bpp | GetAveragePixel32BPP () |
To find the colour under the pointer, taking the differences of pixels around the centre pixel into account. | |
Protected Member Functions | |
virtual BitmapContents | GetContents (BOOL JustMiddle) |
To investigate whether anything has been rendered into a bitmap-based render region. Don't call directly, use OSRenderBitmap::GetContents. | |
Private Member Functions | |
BOOL | AttachDevice (View *, wxDC *, Spread *SpreadToAttach=NULL, bool fOwned=false) |
Most work done in base class, except for the creation of a CCDC member. | |
BOOL | StartRender () |
Most work done in base class, except for the calculation of the address & mask of the centre pixel. | |
Friends | |
class | OSRenderBitmap |
Definition at line 165 of file grndclik.h.
|
Constructor. Most important jobs are to set the VeryMono flag to FALSE, and to set m_DoCompression = TRUE to ensure correct handling of transparencies.
Definition at line 157 of file grndclik.cpp. 00158 : GRenderClick(ClipRegion, ConvertMatrix, ViewScale, Depth, dpi) 00159 { 00160 RenderFlags.VeryMono = FALSE; // simple black&white rendering NOT !!!!! 00161 RenderFlags.HitDetect = FALSE; 00162 m_DoCompression = TRUE; 00163 }
|
|
Destructor. Simple cleanup, which involves calling our base classes.
Definition at line 230 of file grndclik.cpp. 00231 : ~GRenderClick() 00232 { 00233 00234 }
|
|
Most work done in base class, except for the creation of a CCDC member.
Reimplemented from GRenderClick. Reimplemented in GRenderClickColourNoPaper. Definition at line 664 of file grndclik.cpp. 00665 { 00666 00667 // call base class first 00668 if (!GRenderDIB::AttachDevice(pView, DCToAttach, SpreadToAttach, fOwned)) 00669 return FALSE; 00670 /* 00671 // now replace the usual RenderDC with our new one. This makes the type of the CCDC 00672 // correct, so Quality rendering works correctly, for example. 00673 TRY 00674 { 00675 // IMPORTANT: we 'borrow' the HDC from DCToAttach. We must take care when 00676 // deleting this not to delete the HDCs (see the constructor). 00677 RenderDC = new CCDC( DCToAttach, RENDERTYPE_COLOURBITMAP ); 00678 } 00679 CATCH (CMemoryException, e) 00680 { 00681 // Ooer - not enough memory 00682 TRACEALL( _T("No memory for CCDC in GRenderClickColour::AttachDevice") ); 00683 return FALSE; 00684 } 00685 END_CATCH 00686 */ 00687 RenderDC = new wxBufferedDC() ; 00688 m_fOwned = true; 00689 00690 return TRUE; 00691 }
|
|
Dumps the current bitmap onto the current view window, so we can see what is going on. Do not call directly, use OSRenderBitmap::DebugMe.
Reimplemented from GRenderClick. Definition at line 560 of file grndclik.cpp. 00561 { 00562 #if defined(_DEBUG) && 0 // GAT 00563 const INT32 w = WRect.right - WRect.left; 00564 const INT32 h = WRect.bottom - WRect.top; 00565 00566 INT32 Offset = (Stretch/100) * w * (Stretch%100); 00567 Stretch = Stretch%100; 00568 00569 // DIBUtil::InvertAlpha(lpBitmapInfo, lpBits); 00570 DWORD oldComp = lpBitmapInfo->bmiHeader.biCompression; 00571 lpBitmapInfo->bmiHeader.biCompression = BI_RGB; 00572 INT32 ret = ::StretchDIBits( RenderDC->m_hDC, 0,0, w*Stretch, h*Stretch, 00573 0,0,w,h, 00574 lpBits, lpBitmapInfo, 00575 DIB_RGB_COLORS, 00576 SRCCOPY 00577 ); 00578 lpBitmapInfo->bmiHeader.biCompression = oldComp; 00579 // DIBUtil::InvertAlpha(lpBitmapInfo, lpBits); 00580 #endif 00581 }
|
|
To find the colour under the pointer, taking the differences of pixels around the centre pixel into account.
Definition at line 478 of file grndclik.cpp. 00479 { 00480 Pixel32bpp Pix; 00481 INT32 Blue = pMiddle [0]; // Give centre pixel more weight by initialising average 00482 INT32 Green = pMiddle [1]; 00483 INT32 Red = pMiddle [2]; 00484 INT32 Alpha = pMiddle [3]; 00485 00486 // not in the middle - if any byte is not 0xFF then something must have been 00487 // rendered 00488 LPBYTE pSearch = pBits; 00489 UINT32 Count = pBitmapInfo->bmiHeader.biSizeImage >> 2; 00490 UINT32 size = Count+1; 00491 while (Count--) 00492 { 00493 Blue += pSearch[0]; 00494 Green += pSearch[1]; 00495 Red += pSearch[2]; 00496 Alpha += pSearch[3]; 00497 00498 pSearch += 4; 00499 } 00500 00501 //TRACEUSER( "Phil", _T("AvgPix1 B=%d G=%d R=%d A=%d\n"), Blue, Green, Red, Alpha); 00502 Pix.Blue = Blue/size; 00503 Pix.Green = Green/size; 00504 Pix.Red = Red/size; 00505 Pix.Alpha = Alpha/size; 00506 //TRACEUSER( "Phil", _T("AvgPix2 B=%d G=%d R=%d A=%d\n"), Pix.Blue, Pix.Green, Pix.Red, Pix.Alpha); 00507 00508 return Pix; 00509 }
|
|
This sexy little function is what makes my custom colour picker control read the TRUE 32-bit document colour.
Definition at line 447 of file grndclik.cpp. 00448 { 00449 Pixel32bpp Pix; 00450 Pix.Alpha = 0; // Generally there is no alpha channel, so set it to a default 00451 00452 // grab the centre pixels TRUE 32-bit value .... 00453 00454 Pix.Blue = pMiddle [0]; // pointer to byte of centre pixel 00455 Pix.Green = pMiddle [1]; 00456 Pix.Red = pMiddle [2]; 00457 Pix.Alpha = pMiddle [3]; 00458 00459 return Pix; 00460 }
|
|
To investigate whether anything has been rendered into a bitmap-based render region. Don't call directly, use OSRenderBitmap::GetContents.
Reimplemented from GRenderClick. Definition at line 391 of file grndclik.cpp. 00392 { 00393 RECT UsedRect; 00394 00395 if ( 00396 HaveRenderedSomething && 00397 (GetDrawContext()->GetChangedBBox( &UsedRect )) 00398 ) 00399 { 00400 if ( 00401 (UsedRect.right > UsedRect.left) || 00402 (UsedRect.top < UsedRect.bottom) 00403 ) 00404 { 00405 // something has been drawn - is it the middle? 00406 BYTE middleT = pMiddle[3]; // Read transp channel 00407 if (middleT < GRenderRegion::ClickTranspLimit) 00408 return BITMAPCONTENTS_CENTRE; 00409 00410 // if only interested in centre pixel then we're out of here 00411 if (JustMiddle) 00412 return BITMAPCONTENTS_NONE; 00413 00414 // not in the middle - if any byte is not 0xFF then something must have been 00415 // rendered 00416 LPBYTE pSearch = pBits; 00417 size_t Count = pBitmapInfo->bmiHeader.biSizeImage >> 2; 00418 while (Count--) 00419 { 00420 if (pSearch[3] < GRenderRegion::ClickTranspLimit) 00421 return BITMAPCONTENTS_ANY; 00422 pSearch += 4; 00423 } 00424 // else nothing rendered 00425 } 00426 } 00427 00428 return BITMAPCONTENTS_NONE; 00429 }
|
|
Most work done in base class, except for the calculation of the address & mask of the centre pixel.
Reimplemented from GRenderClick. Definition at line 792 of file grndclik.cpp. 00793 { 00794 if (!GRenderDIB::StartRender()) 00795 return FALSE; 00796 00797 // work out the address & mask of the centre pixel 00798 const INT32 w = WRect.width; 00799 const INT32 h = WRect.height; 00800 00801 UINT32 scanlineSize = DIBUtil::ScanlineSize( w, 32 ); 00802 00803 // address is pretty easy 00804 GRenderClick::pMiddle = pBits + (h/2)*scanlineSize; 00805 GRenderClick::pMiddle += (w/2) * 32/8; // Bytes per pixel 00806 00807 // The following is immaterial in 32BPP bitmaps... 00808 // bit within byte is also reasonably straight-forward (and should be independent of 00809 // byte-sex) 00810 MiddleMask = (BYTE) ( (INT32)0x80 >> ((w/2)&7) ); 00811 00812 // If we have been asked to clear out the contents of the bmp, then do it 00813 if (ClearOnStart) 00814 { 00815 // Set it to white 00816 if (pBits!=NULL) 00817 memset(pBits, 0xFF, pBitmapInfo->bmiHeader.biSizeImage); 00818 00819 // Dont do it next time please 00820 ClearOnStart = FALSE; 00821 } 00822 00823 return TRUE; 00824 }
|
|
Reimplemented from GRenderClick. Reimplemented in GRenderClickColourNoPaper. Definition at line 167 of file grndclik.h. |