#include <grndbmp.h>
Inheritance diagram for GRenderBitmap:
Public Member Functions | |
GRenderBitmap (DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi, BOOL Printing=FALSE, UINT32 Dither=XARADITHER_ORDERED_GREY, LPLOGPALETTE pPalette=NULL, BOOL AutoConvert=FALSE) | |
GRenderBitmap constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using. | |
~GRenderBitmap () | |
GRenderBitmap destructor. Frees up the bitmap. | |
OILBitmap * | ExtractBitmap (LPLOGPALETTE pPalette=NULL) |
So that the caller may do what he likes with the bitmap. | |
OILBitmap * | ExtractBitmapCopy (LPLOGPALETTE pPalette=NULL, LPBITMAPINFO pMaskInfo=NULL, LPBYTE pMaskData=NULL, INT32 MaskColour=-1, BOOL LookForDuplicates=FALSE) |
So that the caller may do what he likes with the bitmap. | |
BOOL | GetBitmapData (LPBITMAPINFO *pBitmapInfo, LPBYTE *pBitmapData, BOOL Convert=FALSE) |
LPBITMAPINFO | GetBitmapInfo () |
BOOL | StartRender () |
Uses base class to do normal stuff, then fills bitmap with White as a sort of paper background. | |
virtual BOOL | SetFirstBand () |
Sets up for banded rendering. This class will always band the region into 128 pixel high bands. | |
virtual BOOL | GetNextBand () |
Since this class does not do banded rendering, there are never any more bands. | |
INT32 | GetNumBands () |
The bitmap export and printing both need to know how many bands there will be when doing banded rendering. Since the bands are of a fixed size in GRenderBitmaps we are able to work out how many there will be before hand. This function tells you how many bands there would be if you were to banded render this region. | |
void | SetOverlapBands (BOOL NewVal) |
This function allows to you switch band overlapping on and off. It is off by default. Bands need to be overlapped when printing to stop the error at the edge of dither pattens. | |
BOOL | SetRenderBottomToTop (BOOL NewVal) |
This function allows to you switch the direction that the bands are rendered in. It is bottom to top by default. We need to switch the direction when exporting as a bitmap as the Accusoft code needs it in both directions. | |
INT32 | GetFullRegionHeight () |
The bitmap export needs to know what the total height of the bitmap is when doing banded rendering as the region will be created the height of the band and not the full height of the bitmap. | |
virtual WinRect | CalculateWinRect (Matrix &RenderMatrix, const DocRect &docrect, const double dpi) |
To convert a rectangle in Doc coordinates to a rectangle in Win coordinates taking account of the destination dpi rather than assuming screen dpi. Virtual so that it can be overriden by different render regions if so required. | |
void | UseGreyscaleContextDangerous (void) |
DANGEROUS! Don't use this unless you really know what you're doing. | |
void | StopUsingGreyscaleContextDangerous (void) |
DANGEROUS! Don't use this unless you really know what you're doing. | |
virtual GMATRIX | MakeGavinMatrix (Matrix NewRenderMatrix, DocRect ClipRect, double dPixelsPerInch, BOOL bMasterCapture) |
Make a Gavin Matrix out of a Kernel Matrix. | |
Static Public Member Functions | |
static void | Deinit (void) |
De-initialises the GRenderBitmap class. Mainly used to stop memory leaks after someone has been using the nasty greyscale context bodge (See StartUsingGreyscaleContextDangerous()). | |
static BOOL | DitheringNeeds32bpp (UINT32 Dither) |
Protected Member Functions | |
LPBITMAPINFO | GetLPBits (INT32 Width, INT32 Height, INT32 Depth, LPBYTE *) |
Allocates a bitmap from the CCMalloc heap. | |
void | FreeLPBits (LPBITMAPINFO, LPBYTE) |
Frees the memory allocated in GetLPBits. | |
BOOL | DisplayBits (LPBITMAPINFO lpDisplayBitmapInfo=NULL, LPBYTE lpDisplayBits=NULL) |
None really, except that the base class needs one, so we supply it. | |
BOOL | DoOutputBitmapConversion (LPBITMAPINFO *lpConvInfo, LPBYTE *lpConvBits, LPLOGPALETTE pPalette) |
LPLOGPALETTE | GetConversionPalette () |
Protected Attributes | |
BOOL | OverlapBands |
BOOL | RenderBottomToTop |
UINT32 | DitherType |
UINT32 | uOutputDepth |
LPLOGPALETTE | pConvPalette |
LPBITMAPINFO | lpOutputInfo |
LPBYTE | lpOutputBits |
double | m_dXCentralAdjust |
double | m_dYCentralAdjust |
Private Attributes | |
GDrawContext * | pPreviousGDrawContext |
Static Private Attributes | |
static GDrawContext * | pGreyscaleContext = NULL |
Definition at line 118 of file grndbmp.h.
|
GRenderBitmap constructor. Doesn't do anything actually, just calls base class. INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.
Definition at line 176 of file grndbmp.cpp. 00179 : GRenderDIB( ClipRegion, ConvertMatrix, ViewScale, Depth, dpi) 00180 { 00181 // normally our colour context is obtained by RenderRegion::InitDevice, 00182 // but sadly this requires a RenderWindow, which we ain't got. There must 00183 // be a better way than this, but don't knock it. This must be done BEFORE 00184 // InitDevice as that renders default attributes, which tend to rely on a colour context 00185 00186 if (RenderView==NULL) 00187 CurrentColContext = ColourContext::GetGlobalDefault(COLOURMODEL_RGBT); 00188 00189 // we do not want to overlap the bands by default 00190 OverlapBands = FALSE; 00191 00192 // We do want to render bottom to top by default 00193 RenderBottomToTop = TRUE; 00194 00195 // Render flag stuff 00196 RenderFlags.Printing = Printing; 00197 00198 // This next bit was added to cope with the conversion needed when using certain 00199 // dithering techniques 00200 DitherType = Dither; 00201 uOutputDepth = Depth; // If different from the actual RR bpp, then the bitmap will 00202 // be converted before output 00203 lpOutputInfo = NULL; 00204 lpOutputBits = NULL; 00205 00206 m_dXCentralAdjust = 0; 00207 m_dYCentralAdjust = 0; 00208 00209 pConvPalette = pPalette; 00210 00211 if (AutoConvert && uOutputDepth<32) 00212 { 00213 // The dithering we are using requires us to render to 32bpp and then convert it down 00214 // to our output bpp at the end 00215 00216 // Force rendering to 32bpp, we will convert it to 'Depth' at the end 00217 uBitmapDepth = 32; 00218 } 00219 00220 pPreviousGDrawContext = NULL; 00221 }
|
|
GRenderBitmap destructor. Frees up the bitmap.
Definition at line 370 of file grndbmp.cpp. 00371 { 00372 // we should NOT delete the CurrentColContext cos we didn't alloc it - we just 00373 // got a pointer to something allocated by somebody else 00374 00375 if (lpOutputInfo!=NULL || lpOutputBits!=NULL) 00376 { 00377 // Free up the conversion bitmap 00378 FreeDIB(lpOutputInfo, lpOutputBits); 00379 lpOutputInfo = NULL; 00380 lpOutputBits = NULL; 00381 } 00382 00383 // Free up the bitmap here, as the call to FreeLPBits in the 00384 // GRenderDIB will not call the correct version (the virtual-ness will be 00385 // broken as it is called from a destructor 00386 if (pBitmapInfo!=NULL) 00387 { 00388 // NB Export rendering can be cancelled by user 00389 // Hence can be in the middle of offscreen rendering at this point 00390 FreeOffscreenState(); 00391 pBitmapInfo = NULL; 00392 pBits = NULL; 00393 } 00394 00395 // Make sure we restore the state of the GDrawContext if our client forgot to 00396 // turn off the context replacement. See UseGreyscaleContextDangerous(), below. 00397 if (pPreviousGDrawContext != NULL) 00398 { 00399 if (SetTempDrawContext(pPreviousGDrawContext) != pGreyscaleContext) 00400 { 00401 ERROR3("Not pGreyscaleContext when restoring"); 00402 } 00403 pPreviousGDrawContext = NULL; 00404 } 00405 }
|
|
To convert a rectangle in Doc coordinates to a rectangle in Win coordinates taking account of the destination dpi rather than assuming screen dpi. Virtual so that it can be overriden by different render regions if so required.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 298 of file grndbmp.cpp. 00300 { 00301 // lets get the Rect into screen co-ords so we can use our big screen bitmap 00302 // Use a version of OSRenderRegion::DocRectToWin that uses the actual dpi we have stored 00303 // in PixelsPerInch and that tries to sort out the pixel problems 00304 return OSRenderRegion::BitmapDocRectToWin( RenderMatrix, docrect, dpi ); 00305 }
|
|
De-initialises the GRenderBitmap class. Mainly used to stop memory leaks after someone has been using the nasty greyscale context bodge (See StartUsingGreyscaleContextDangerous()).
Definition at line 1480 of file grndbmp.cpp. 01481 { 01482 ERROR3IF(GD != NULL && GD == pGreyscaleContext, "GRenderBitmap greyscale context still in use"); 01483 01484 if (pGreyscaleContext != NULL) 01485 { 01486 delete pGreyscaleContext; 01487 pGreyscaleContext = NULL; 01488 } 01489 }
|
|
None really, except that the base class needs one, so we supply it.
Reimplemented from GRenderDIB. Definition at line 800 of file grndbmp.cpp. 00801 { 00802 return TRUE; 00803 }
|
|
Definition at line 237 of file grndbmp.cpp. 00238 { 00239 return (Dither != XARADITHER_ORDERED_GREY); 00240 }
|
|
Definition at line 1196 of file grndbmp.cpp. 01197 { 01198 #if !defined(EXCLUDE_FROM_RALPH) 01199 ERROR3IF(lpConvInfo == NULL, "NULL info pointer passed to GRenderBitmap::DoOutputBitmapConversion"); 01200 if (lpConvInfo == NULL) 01201 return FALSE; 01202 01203 ERROR3IF(lpConvBits == NULL, "NULL data pointer passed to GRenderBitmap::DoOutputBitmapConversion"); 01204 if (lpConvBits == NULL) 01205 return FALSE; 01206 01207 if (uOutputDepth == uBitmapDepth) 01208 { 01209 // No conversion is needed !! 01210 *lpConvInfo = pBitmapInfo; 01211 *lpConvBits = pBits; 01212 01213 if(m_bEnableConversion && m_DoCompression) 01214 { 01215 UINT32 Width = pBitmapInfo->bmiHeader.biWidth; 01216 UINT32 Height = pBitmapInfo->bmiHeader.biHeight; 01217 BYTE* lpOutput = pBits; 01218 01219 DIBConvert* Converter = DIBConvert::Create( 32, 32, Width, NULL, 0 ); 01220 01221 if(Converter != NULL) 01222 { 01223 Converter->Convert(pBits, lpOutput, Height); 01224 delete Converter; 01225 Converter = NULL; 01226 01227 // Force the bitmap to be reinitialised when StartRender is next called 01228 ForceInitBmpBits = TRUE; 01229 01230 ENSURE(GetMasterCapture()==NULL || MasterCaptureIsCurrent(), "Bitmap converted in-place while captures are running\n"); 01231 } 01232 } 01233 01234 return TRUE; 01235 } 01236 01237 // Blank the pointer in case of an error 01238 *lpConvInfo = NULL; 01239 *lpConvBits = NULL; 01240 01241 // We must need to do some Bitmap conversion then .... 01242 UINT32 Width = pBitmapInfo->bmiHeader.biWidth; 01243 UINT32 Height = pBitmapInfo->bmiHeader.biHeight; 01244 01245 // Make a converter object 01246 DIBConvert* Converter = DIBConvert::Create( uBitmapDepth, uOutputDepth, Width, pPalette, DitherType ); 01247 ERROR3IF(Converter == NULL, "Failed to create DIBConvert object in GRenderBitmap::DoOutputBitmapConversion"); 01248 if (Converter == NULL) 01249 return FALSE; 01250 01251 if (lpOutputInfo != NULL || lpOutputBits != NULL) 01252 { 01253 // Free the existing bitmap data 01254 FreeDIB(lpOutputInfo, lpOutputBits); 01255 01256 lpOutputInfo = NULL; 01257 lpOutputBits = NULL; 01258 } 01259 01260 // Allocate some memory for the converted bitmap 01261 lpOutputInfo = AllocDIB(Width, Height, uOutputDepth, &lpOutputBits); 01262 ERROR3IF(lpOutputInfo == NULL, "Failed to allocate conversion info in GRenderBitmap::DoOutputBitmapConversion"); 01263 ERROR3IF(lpOutputBits == NULL, "Failed to allocate conversion data in GRenderBitmap::DoOutputBitmapConversion"); 01264 if (lpOutputInfo == NULL || lpOutputBits == NULL) 01265 return FALSE; 01266 01267 // Do the conversion 01268 BOOL ok = Converter->Convert(pBits, lpOutputBits, Height); 01269 delete Converter; 01270 01271 if (ok) 01272 { 01273 *lpConvInfo = lpOutputInfo; 01274 *lpConvBits = lpOutputBits; 01275 } 01276 01277 return ok; 01278 #else 01279 return FALSE; 01280 #endif 01281 }
|
|
So that the caller may do what he likes with the bitmap.
Definition at line 819 of file grndbmp.cpp. 00820 { 00821 if (pBitmapInfo && pBits) 00822 { 00823 LPBITMAPINFO lpConvInfo; 00824 LPBYTE lpConvBits; 00825 00826 BOOL DeletePalette = FALSE; 00827 00828 if(!pPalette) 00829 { 00830 pPalette = GetConversionPalette(); 00831 if (pPalette && pPalette != pConvPalette) 00832 DeletePalette = TRUE; 00833 } 00834 00835 BOOL ok = DoOutputBitmapConversion(&lpConvInfo, &lpConvBits, pPalette); 00836 ERROR3IF(!ok, "Output conversion failed in GRenderBitmap::ExtractBitmap"); 00837 if (!ok) 00838 { 00839 if(DeletePalette) 00840 CCFree(pPalette); 00841 return NULL; 00842 } 00843 00844 CWxBitmap *OILBM = new CWxBitmap( lpConvInfo, lpConvBits ); 00845 if (OILBM) 00846 { 00847 // Setup the Oil bitmap's pallete 00848 RGBQUAD* pOilPalette = OILBM->BMInfo->bmiColors; 00849 PALETTEENTRY* pPaletteEntry = pPalette->palPalEntry; 00850 00851 // Copy the palette entries over, we cannot copy a structure at a time because 00852 // the bytes are in different orders 00853 for (DWORD i=0; i< OILBM->BMInfo->bmiHeader.biClrUsed; i++) 00854 { 00855 pOilPalette[i].rgbBlue = pPaletteEntry[i].peBlue; 00856 pOilPalette[i].rgbGreen = pPaletteEntry[i].peGreen; 00857 pOilPalette[i].rgbRed = pPaletteEntry[i].peRed; 00858 pOilPalette[i].rgbReserved = pPaletteEntry[i].peFlags; 00859 } 00860 00861 if (lpConvBits == pBits) 00862 { 00863 // ensure empty offscreen stack 00864 //#ifdef _DEBUG 00865 // DumpCaptureStack(); 00866 //#endif 00867 ENSURE(MasterCaptureIsCurrent(), "Extract bitmap whilst rendering offscreen not finished!"); 00868 00869 // bytes owned by CWxBitmap now - zero them so we don't free them up 00870 SetBitmapPointers(NULL, NULL); 00871 } 00872 00873 if (lpConvBits == lpOutputBits) 00874 { 00875 // bytes owned by CWxBitmap now - zero them so we don't free them up 00876 lpOutputInfo = NULL; 00877 lpOutputBits = NULL; 00878 } 00879 00880 if(DeletePalette) 00881 CCFree(pPalette); 00882 00883 return OILBM; 00884 } 00885 00886 if(DeletePalette) 00887 CCFree(pPalette); 00888 } 00889 00890 return NULL; 00891 }
|
|
So that the caller may do what he likes with the bitmap.
Definition at line 920 of file grndbmp.cpp. 00923 { 00924 ERROR3IF(MaskColour==-2,"Someone`s using a MaskColour of -2!!! Please Correct!"); 00925 BOOL bBrowserPalette = FALSE; 00926 00927 if(!pPalette) 00928 bBrowserPalette = TRUE; 00929 00930 if (pBitmapInfo && pBits) 00931 { 00932 LPBITMAPINFO lpCopyInfo = NULL; 00933 LPBYTE lpCopyBits = NULL; 00934 LPBITMAPINFO lpConvInfo = NULL; 00935 LPBYTE lpConvBits = NULL; 00936 00937 BOOL DeletePalette = FALSE; 00938 00939 if (!pPalette) 00940 { 00941 pPalette = GetConversionPalette(); 00942 DeletePalette = (pPalette && pPalette != pConvPalette); 00943 } 00944 00945 if (pPalette && MaskColour >= 0 && MaskColour < pPalette->palNumEntries) 00946 { 00947 pPalette->palPalEntry[MaskColour].peRed = 255; 00948 pPalette->palPalEntry[MaskColour].peGreen = 255; 00949 pPalette->palPalEntry[MaskColour].peBlue = 255; 00950 pPalette->palPalEntry[MaskColour].peFlags = 255; 00951 } 00952 00953 BOOL ok = DoOutputBitmapConversion(&lpConvInfo, &lpConvBits, pPalette); 00954 ERROR3IF(!ok, "Output conversion failed in GRenderBitmap::ExtractBitmap"); 00955 if (!ok) 00956 { 00957 if (DeletePalette) 00958 CCFree(pPalette); 00959 return NULL; 00960 } 00961 00962 if (lpConvBits == pBits) 00963 { 00964 BOOL CopyOK = DIBUtil::CopyBitmap(pBitmapInfo, pBits, &lpCopyInfo, &lpCopyBits); 00965 00966 if (!CopyOK) 00967 { 00968 ERROR3("Failed to copy bitmap in ExtractBitmapCopy"); 00969 if (DeletePalette) 00970 CCFree(pPalette); 00971 return NULL; 00972 } 00973 } 00974 else 00975 { 00976 lpCopyInfo = lpConvInfo; 00977 lpCopyBits = lpConvBits; 00978 } 00979 00980 if (pMaskInfo && pMaskData && MaskColour>=0) 00981 { 00982 // We've been given a mask for the bitmap ... 00983 if (!DIBUtil::MakeTransparentBitmap(lpCopyInfo, lpCopyBits, pMaskInfo, pMaskData, MaskColour)) 00984 { 00985 ERROR3("Failed to apply mask in GRenderBitmap::ExtractBitmapCopy"); 00986 if (DeletePalette) 00987 CCFree(pPalette); 00988 FreeDIB(lpCopyInfo, lpCopyBits); 00989 return NULL; 00990 } 00991 } 00992 00993 CWxBitmap *OILBM = new CWxBitmap( lpCopyInfo, lpCopyBits ); 00994 if (OILBM) 00995 { 00996 // Make sure that the bitmap has a width and height which are an integral 00997 // number of pixels. 00998 INT32 width = (INT32)(( OILBM->BMInfo->bmiHeader.biWidth ) * 72000 / 96.0); 00999 INT32 height = (INT32)(( OILBM->BMInfo->bmiHeader.biHeight ) * 72000 / 96.0); 01000 OILBM->SetRecommendedWidth( width ); 01001 OILBM->SetRecommendedHeight( height ); 01002 01003 // Setup the Oil bitmap's pallete 01004 RGBQUAD* pOilPalette = OILBM->BMInfo->bmiColors; 01005 // Only change the palette if there is on already present 01006 // REMEMBER bitmaps with more than 8bpp generally do not have palettes 01007 if (pPalette != NULL) 01008 { 01009 // This will be the optimised palette 01010 INT32 ColoursInPal = pPalette->palNumEntries; 01011 // The optimised palette will NOT contain the transparent colour 01012 // Therefore, if we have a transparent colour then increment our count 01013 if (MaskColour >= 0) 01014 { 01015 // We have to ensure that the number of colours we are requesting will 01016 // be enough to contain the transparent colour index. 01017 if (MaskColour > ColoursInPal) 01018 { 01019 // Not enough entries in out palette 01020 // So expand it to include the mask colour 01021 ColoursInPal = MaskColour + 1; 01022 } 01023 else 01024 ColoursInPal++; 01025 } 01026 01027 // The bitmap header will contain the colour depth number of colours 01028 INT32 MaxColours = OILBM->BMInfo->bmiHeader.biClrUsed; 01029 // Ensure that we have not gone over this limit 01030 if (ColoursInPal > MaxColours) 01031 ColoursInPal = MaxColours; 01032 01033 // Copy the palette entries over, we cannot copy a structure at a time because 01034 // the bytes are in different orders 01035 PALETTEENTRY* pPaletteEntry = pPalette->palPalEntry; 01036 for (INT32 i = 0; i < MaxColours; i++) 01037 { 01038 if (i == MaskColour) 01039 { 01040 // Force the masked colour to White, so it looks right 01041 // even if we can't render it with transparency 01042 pOilPalette[i].rgbBlue = 255; 01043 pOilPalette[i].rgbGreen = 255; 01044 pOilPalette[i].rgbRed = 255; 01045 pOilPalette[i].rgbReserved = 255; 01046 } 01047 else if (i > ColoursInPal) 01048 { 01049 // Force any unused colours to be black 01050 pOilPalette[i].rgbBlue = 0; 01051 pOilPalette[i].rgbGreen = 0; 01052 pOilPalette[i].rgbRed = 0; 01053 pOilPalette[i].rgbReserved = 0; 01054 } 01055 else 01056 { 01057 pOilPalette[i].rgbBlue = pPaletteEntry[i].peBlue; 01058 pOilPalette[i].rgbGreen = pPaletteEntry[i].peGreen; 01059 pOilPalette[i].rgbRed = pPaletteEntry[i].peRed; 01060 pOilPalette[i].rgbReserved = 0; 01061 } 01062 } 01063 01064 // Only set up the required number of palette entries 01065 OILBM->BMInfo->bmiHeader.biClrUsed = ColoursInPal; 01066 } 01067 01068 if (lpCopyBits == pBits) 01069 { 01070 // bytes owned by CWxBitmap now - zero them so we don't free them up 01071 SetBitmapPointers(NULL, NULL); 01072 01073 // ensure empty offscreen stack 01074 ENSURE(MasterCaptureIsCurrent(), "Extract bitmap whilst rendering offscreen not finished!"); 01075 } 01076 01077 if (lpCopyBits == lpOutputBits) 01078 { 01079 // bytes owned by CWxBitmap now - zero them so we don't free them up 01080 lpOutputInfo = NULL; 01081 lpOutputBits = NULL; 01082 } 01083 01084 if (LookForDuplicates) 01085 { 01086 // This check was not here before 25/4/97 01087 // Check to see if this bitmap exists in the global bitmap list 01088 // This will actually check the bitmap itself to see if it is the same 01089 // rather than doing a simple and explicit pointer check. 01090 GlobalBitmapList * pBmpList = GetApplication()->GetGlobalBitmapList(); 01091 OILBitmap* pExistingBmp = NULL; 01092 if (pBmpList) 01093 pExistingBmp = pBmpList->FindDuplicateBitmap(OILBM); 01094 if (pExistingBmp) 01095 { 01096 TRACEUSER( "Neville", _T("This bitmap already exists. Re-using existing OILBitmap.\n")); 01097 // There's already an existing OIL bitmap we can use, 01098 // so we'll make a new kernel bitmap out of it ... 01099 if (DeletePalette) 01100 CCFree(pPalette); 01101 delete OILBM; 01102 return pExistingBmp; 01103 } 01104 } 01105 if (DeletePalette) 01106 CCFree(pPalette); 01107 01108 return OILBitmap::Attach(OILBM, FALSE); 01109 } 01110 01111 if(DeletePalette) 01112 CCFree(pPalette); 01113 } 01114 01115 return NULL; 01116 }
|
|
Frees the memory allocated in GetLPBits.
Reimplemented from GRenderDIB. Definition at line 777 of file grndbmp.cpp. 00778 { 00779 // Free up the memory. Not from Limited Heap 00780 FreeDIB(lpBMI, lpB, NULL, FALSE); 00781 }
|
|
Definition at line 1129 of file grndbmp.cpp. 01130 { 01131 ERROR3IF(pBmpInfo == NULL, "NULL info pointer passed to GetBitmapData"); 01132 if (pBmpInfo == NULL) 01133 return FALSE; 01134 01135 ERROR3IF(pBmpData == NULL, "NULL data pointer passed to GetBitmapData"); 01136 if (pBmpData == NULL) 01137 return FALSE; 01138 01139 if (!Convert) 01140 { 01141 *pBmpInfo = pBitmapInfo; 01142 *pBmpData = pBits; 01143 01144 if(m_bEnableConversion && m_DoCompression) 01145 { 01146 UINT32 Width = pBitmapInfo->bmiHeader.biWidth; 01147 UINT32 Height = pBitmapInfo->bmiHeader.biHeight; 01148 BYTE* lpOutput = *pBmpData; 01149 01150 DIBConvert* Converter = DIBConvert::Create( 32, 32, Width, NULL, 0 ); 01151 01152 if(Converter != NULL) 01153 { 01154 Converter->Convert(pBits, lpOutput, Height); 01155 delete Converter; 01156 Converter = NULL; 01157 01158 // Force the bitmap to be reinitialised when StartRender is next called 01159 ForceInitBmpBits = TRUE; 01160 01161 ENSURE(GetMasterCapture()==NULL || MasterCaptureIsCurrent(), "Bitmap converted in-place while captures are running\n"); 01162 } 01163 } 01164 01165 return TRUE; 01166 } 01167 01168 LPBITMAPINFO lpConvInfo=NULL; 01169 LPBYTE lpConvBits=NULL; 01170 01171 LPLOGPALETTE pPalette = GetConversionPalette(); 01172 01173 BOOL ok = DoOutputBitmapConversion(&lpConvInfo, &lpConvBits, pPalette); 01174 ERROR3IF(!ok, "Output conversion failed in GRenderBitmap::GetBitmapData"); 01175 01176 *pBmpInfo = lpConvInfo; 01177 *pBmpData = lpConvBits; 01178 01179 if (pPalette != pConvPalette) 01180 CCFree(pPalette); 01181 01182 return ok; 01183 }
|
|
Definition at line 146 of file grndbmp.h. 00146 { return pBitmapInfo; }
|
|
Definition at line 1294 of file grndbmp.cpp. 01295 { 01296 #if !defined(EXCLUDE_FROM_RALPH) 01297 if (uOutputDepth>8) 01298 return NULL; // Must be 8bpp or less 01299 01300 if (pConvPalette) 01301 return pConvPalette; // Use specified palette if one exists 01302 01303 //ASSERT(FALSE); // we should have a palette!! sjk SMFIX 01304 // most times we should have a palette but for now animated gifs like to use this code so we will leave it for now 01305 01306 LPLOGPALETTE pPalette; 01307 size_t TotalPal; 01308 01309 switch (uOutputDepth) 01310 { 01311 case 8: 01312 // Get the standard 256 colour palette 01313 TotalPal = sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 ); 01314 pPalette = (LPLOGPALETTE)CCMalloc( TotalPal ); 01315 if (pPalette != NULL) 01316 { 01317 LPLOGPALETTE pRecPalette = GetErrorDiffPalette(); 01318 if (pRecPalette) 01319 { 01320 memcpy(pPalette, pRecPalette, TotalPal); 01321 } 01322 else 01323 { 01324 CCFree(pPalette); 01325 return NULL; 01326 } 01327 } 01328 break; 01329 01330 case 4: 01331 TotalPal = sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 16 ); 01332 pPalette = (LPLOGPALETTE)CCMalloc( TotalPal ); 01333 if (pPalette != NULL) 01334 { 01335 // Make a standard 16 colour palette 01336 OutputDIB::Fix16ColourPalette(pPalette); 01337 } 01338 break; 01339 01340 case 1: 01341 TotalPal = sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 2 ); 01342 pPalette = (LPLOGPALETTE)CCMalloc( TotalPal ); 01343 if (pPalette != NULL) 01344 { 01345 // Make a simple black and white palette 01346 OutputDIB::FixBlackAndWhitePalette(pPalette); 01347 } 01348 break; 01349 01350 default: 01351 ERROR3("Bad colour depth in GRenderBitmap::GetConversionPalette"); 01352 pPalette = NULL; 01353 break; 01354 } 01355 01356 return pPalette; 01357 #else 01358 return NULL; 01359 #endif 01360 }
|
|
The bitmap export needs to know what the total height of the bitmap is when doing banded rendering as the region will be created the height of the band and not the full height of the bitmap.
Definition at line 460 of file grndbmp.cpp. 00461 { 00462 // Find out the actual size in pixels of this render region 00463 // Use the same method that is used to construct the matrix and we use in 00464 // the bitmap options dialog box to work out the size so that we are consistent 00465 Matrix Identity; // default construction is an identity matrix 00466 WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, RegionRect, PixelsPerInch ); 00467 return Rect.height; 00468 }
|
|
Allocates a bitmap from the CCMalloc heap.
Reimplemented from GRenderDIB. Definition at line 754 of file grndbmp.cpp. 00755 { 00756 // Get a DIB out of the CCMalloc heap 00757 LPBITMAPINFO bmInfo = NULL; 00758 bmInfo = AllocDIB( abs(Width), abs(Height), Depth, lplpBits, NULL, FALSE); 00759 00760 // return it. 00761 return bmInfo; 00762 }
|
|
Since this class does not do banded rendering, there are never any more bands.
Reimplemented from GRenderDIB. Reimplemented in GRenderOptPalette. Definition at line 620 of file grndbmp.cpp. 00621 { 00622 // Go find the next band, if there is one. 00623 // Give back the memory we already have 00624 if (pBitmapInfo!=NULL) 00625 { 00626 FreeOffscreenState(); 00627 pBitmapInfo = NULL; 00628 pBits = NULL; 00629 } 00630 00631 // ENSURE(GetCaptureDepth()==0, "Can't set a band while there are any captures running"); 00632 ENSURE(GetCaptureDepth()==0 || MasterCaptureIsCurrent(), "Can't set a band while there are any non-master captures running\n"); 00633 00634 // if this is not a banded render region, then there are no more bands 00635 if (!IsBanded()) 00636 return FALSE; 00637 00638 if (RenderBottomToTop) 00639 { 00640 // Render from the bottom upwards 00641 // See if we are out of bands 00642 if ((CurrentClipRect.hi.y >= RegionRect.hi.y) || (IsLastBand)) 00643 return FALSE; 00644 } 00645 else 00646 { 00647 // Render from the top downwards 00648 // See if we are out of bands 00649 if ((CurrentClipRect.lo.y <= RegionRect.lo.y) || (IsLastBand)) 00650 return FALSE; 00651 } 00652 00653 // we're going to need to be re-rendered 00654 IsPaperRendered = FALSE; 00655 IsInkRenderStarted = FALSE; 00656 00657 // Get the number of scan lines we are prepared to do 00658 INT32 MaxScanLines = FIXEDBANDSIZE; 00659 00660 // Work out how many scan lines there are left to do 00661 double TruePixelHeight = 72000.0 / PixelsPerInch; //.MakeDouble(); 00662 // Removed due to problems with printing feathers (see comment at top of file) 00663 // ERROR3IF(ScaleFactor.MakeDouble() != 1.0, "ScaleFactor not 1, see comment at top of grndbmp.cpp"); 00664 00665 INT32 Height = 0; 00666 if (RenderBottomToTop) 00667 { 00668 // Render from the bottom upwards 00669 Height = (INT32) ((double)(RegionRect.hi.y - CurrentClipRect.hi.y) / TruePixelHeight); 00670 } 00671 else 00672 { 00673 // Render from the top downwards 00674 Height = (INT32) ((double)(CurrentClipRect.lo.y - RegionRect.lo.y ) / TruePixelHeight); 00675 } 00676 00677 // see if there are enought to bother with 00678 IsWaitingForRAM = FALSE; 00679 00680 // Do what we can 00681 INT32 ScanLinesToDo = (MaxScanLines < Height) ? MaxScanLines : Height; 00682 if (ScanLinesToDo==Height) 00683 IsLastBand = TRUE; 00684 else 00685 IsLastBand = FALSE; 00686 00687 // Find out how big in millipoints we can do 00688 MILLIPOINT MaxHeight = (MILLIPOINT) (TruePixelHeight * (double)ScanLinesToDo); 00689 00690 DocRect NewClipRect = CurrentClipRect; 00691 if (RenderBottomToTop) 00692 { 00693 // Render from the bottom upwards 00694 // Set up the new clip rect ready 00695 NewClipRect.lo.y = CurrentClipRect.hi.y; 00696 NewClipRect.hi.y = NewClipRect.lo.y + MaxHeight; 00697 00698 // if we want to overlap the bands, make an adjustment 00699 if (OverlapBands) 00700 NewClipRect.lo.y -= (INT32)(2 * TruePixelHeight); 00701 00702 // Sanity check 00703 if ((NewClipRect.hi.y > RegionRect.hi.y) || (IsLastBand)) 00704 NewClipRect.hi.y = RegionRect.hi.y; 00705 } 00706 else 00707 { 00708 // Render from the top downwards 00709 // Set up the new clip rect ready 00710 NewClipRect.hi.y = CurrentClipRect.lo.y; 00711 NewClipRect.lo.y = NewClipRect.hi.y - MaxHeight; 00712 00713 // if we want to overlap the bands, make an adjustment 00714 if (OverlapBands) 00715 NewClipRect.hi.y -= (INT32)(2 * TruePixelHeight); 00716 00717 // Sanity check 00718 if ((NewClipRect.lo.y < RegionRect.lo.y) || (IsLastBand)) 00719 NewClipRect.lo.y = RegionRect.lo.y; 00720 } 00721 00722 // Make sure that we are not dealing with an empty rect 00723 if (NewClipRect.Height()==0) 00724 return FALSE; 00725 00726 // Set the new clip rect up ready for rendering 00727 SetClipRect(NewClipRect); 00728 00729 // we're going to need to be re-rendered 00730 IsPaperRendered = FALSE; 00731 IsInkRenderStarted = FALSE; 00732 TRACEUSER("Gavin",_T("GRenderBitmap::GetNextBand - RenderFlags.Rendering = FALSE;\n")); 00733 RenderFlags.Rendering = FALSE; 00734 00735 // Say it all worked 00736 return TRUE; 00737 }
|
|
The bitmap export and printing both need to know how many bands there will be when doing banded rendering. Since the bands are of a fixed size in GRenderBitmaps we are able to work out how many there will be before hand. This function tells you how many bands there would be if you were to banded render this region.
Definition at line 424 of file grndbmp.cpp. 00425 { 00426 // Find out how big in millipoints we can do 00427 double TruePixelHeight = 72000.0 / PixelsPerInch; //.MakeDouble(); 00428 00429 // Removed due to problems with printing feathers (see comment at top of file) 00430 // ERROR3IF(ScaleFactor.MakeDouble() != 1.0, "ScaleFactor not 1, see comment at top of grndbmp.cpp"); 00431 00432 // Work out how many scan lines That works out to be 00433 INT32 Height = (INT32)((double)RegionRect.Height() / TruePixelHeight); 00434 00435 // count the bands 00436 INT32 Bands = 0; 00437 while (Height>0) 00438 { 00439 Bands++; 00440 Height -= FIXEDBANDSIZE; 00441 } 00442 00443 // say how many we found 00444 return Bands; 00445 }
|
|
Make a Gavin Matrix out of a Kernel Matrix.
Reimplemented from GRenderRegion. Reimplemented in PrintingMaskedRenderRegion. Definition at line 321 of file grndbmp.cpp. 00322 { 00323 GMATRIX gmat; 00324 // Get the scale factors from the original render matrix 00325 FIXED16 abcd[4]; 00326 NewRenderMatrix.GetComponents( abcd, NULL ); 00327 00328 // Use them to call DocRect to win on the clipping region, without attempting any translation. 00329 // Thus, the DocCoord cliprect gets turned directly into a Windows pixel values cliprect! 00330 Matrix UnscrolledRender(abcd[0], abcd[1], abcd[2], abcd[3], 0, 0); 00331 00332 // in order to get Gavin's matrix calcs to agree with ours, we have to force him to 00333 // round before shifting down. We do this by adding half a pixel to the offsets in 00334 // his matrices. There is a school of thought which says that his matrix code 00335 // should be made to round, but it might have unpleasant side-effects. For now, we do 00336 // it this way. A pixel is 1<<(FX+16), so half a pixel is this incantation: 00337 00338 // sjk's (5/12/00) preferred version as this works with the decimal places that may be in PixelsPerInch 00339 const XLONG Mult = (INT32)(dPixelsPerInch*(double)(1 << FX) + 0.5); 00340 00341 gmat.AX = ( (XLONG)abcd[0].GetRawLong() * Mult ) / XLONG(72000); 00342 gmat.AY = ( (XLONG)abcd[1].GetRawLong() * Mult ) / XLONG(72000); 00343 gmat.BX = ( (XLONG)abcd[2].GetRawLong() * Mult ) / XLONG(72000); 00344 gmat.BY = ( (XLONG)abcd[3].GetRawLong() * Mult ) / XLONG(72000); 00345 00346 // Work out the offsets in the GMatrix, taking into account special handling 00347 // to centralise the drawing within the bitmap 00348 // If we're making the matrix for the master capture 00349 // Then DO centralise teh rendering within the whole-pixel bitmap 00350 // Else DON'T centralise again, just re-use the offsets we calculated the first time 00351 OSRenderRegion::CalculateGavinOffsetsWinRect(UnscrolledRender, ClipRect, dPixelsPerInch, &gmat, bMasterCapture, &m_dXCentralAdjust, &m_dYCentralAdjust); 00352 00353 return gmat; 00354 }
|
|
Sets up for banded rendering. This class will always band the region into 128 pixel high bands.
Reimplemented from GRenderDIB. Definition at line 523 of file grndbmp.cpp. 00524 { 00525 // if we are already banded, or we already have a bitmap, then stop looking 00526 // SMFIX we do want to come in here twice - once sometimes to do the palette, the second time to do the render 00527 // if (IsBanded() || lpBitmapInfo!=NULL) 00528 // return TRUE; 00529 00530 // ENSURE(GetCaptureDepth()==0, "Can't set a band while there are any captures running"); 00531 ENSURE(GetCaptureDepth()==0 || MasterCaptureIsCurrent(), "Can't set a band while there are any non-master captures running\n"); 00532 00533 // They can be merged for the time being 00534 CanRegionBeMerged = TRUE; 00535 00536 // Make sure the InitDevice has been called. 00537 if (!RenderFlags.ValidDevice) 00538 { 00539 // Device needs to be initialised 00540 if (!InitDevice()) 00541 { 00542 // Something's gone wrong - inform the user. 00543 TRACE( _T("InitDevice failed in Render Region")); 00544 return FALSE; 00545 } 00546 00547 // Make sure we don't do this again for this render region 00548 RenderFlags.ValidDevice = TRUE; 00549 } 00550 00551 // Work out how many scan lines there are 00552 double TruePixelHeight = 72000.0 / PixelsPerInch; //.MakeDouble(); 00553 // Removed due to problems with printing feathers (see comment at top of file) 00554 // ERROR3IF(ScaleFactor.MakeDouble() != 1.0, "ScaleFactor not 1, see comment at top of grndbmp.cpp"); 00555 INT32 Height = (INT32) ((double)(RegionRect.hi.y - RegionRect.lo.y) / TruePixelHeight); 00556 00557 // Work out how many scan lines we could fit into the available ram 00558 INT32 MaxScanLines = FIXEDBANDSIZE; 00559 00560 // See if we can do it 00561 if (MaxScanLines>=Height) 00562 { 00563 // No Banding needed 00564 IsRegionBanded = FALSE; 00565 IsWaitingForRAM = FALSE; 00566 IsLastBand = TRUE; 00567 return TRUE; 00568 } 00569 else 00570 { 00571 // Lets band this region then 00572 IsRegionBanded = TRUE; 00573 IsWaitingForRAM = FALSE; 00574 IsLastBand = FALSE; 00575 CanRegionBeMerged = FALSE; 00576 00577 // Find out how big in millipoints we can do 00578 MILLIPOINT MaxHeight = (MILLIPOINT)(TruePixelHeight * (double)MaxScanLines); 00579 00580 // Set up the new clip rect ready 00581 DocRect NewClipRect = CurrentClipRect; 00582 if (RenderBottomToTop) 00583 { 00584 // Render from the bottom upwards 00585 NewClipRect.hi.y = NewClipRect.lo.y + MaxHeight; 00586 00587 // Sanity check 00588 if (NewClipRect.hi.y > CurrentClipRect.hi.y) 00589 NewClipRect.hi.y = CurrentClipRect.hi.y; 00590 } 00591 else 00592 { 00593 // Render from the top downwards 00594 NewClipRect.lo.y = NewClipRect.hi.y - MaxHeight; 00595 00596 // Sanity check 00597 if (NewClipRect.lo.y < CurrentClipRect.lo.y) 00598 NewClipRect.lo.y = CurrentClipRect.lo.y; 00599 } 00600 00601 // Set the new clip rect up ready for rendering 00602 SetClipRect(NewClipRect); 00603 return TRUE; 00604 } 00605 }
|
|
This function allows to you switch band overlapping on and off. It is off by default. Bands need to be overlapped when printing to stop the error at the edge of dither pattens.
Definition at line 484 of file grndbmp.cpp. 00485 { 00486 OverlapBands = NewVal; 00487 }
|
|
This function allows to you switch the direction that the bands are rendered in. It is bottom to top by default. We need to switch the direction when exporting as a bitmap as the Accusoft code needs it in both directions.
Definition at line 503 of file grndbmp.cpp. 00504 { 00505 BOOL OldVal = RenderBottomToTop; 00506 RenderBottomToTop = NewVal; 00507 return OldVal; 00508 }
|
|
Uses base class to do normal stuff, then fills bitmap with White as a sort of paper background.
Reimplemented from GRenderRegion. Reimplemented in MaskedRenderRegion. Definition at line 258 of file grndbmp.cpp. 00259 { 00260 // call base class first 00261 const BOOL ok = GRenderDIB::StartRender(); 00262 if (!ok) 00263 return FALSE; 00264 /* 00265 In an attempt to standardise things, all bmp initing is now done by the 00266 InitBmpBits() virtual function. I am pretty sure that in the past, double 00267 bmp initialisation was occuring 00268 ie here, and in the GetDrawContext()->SetupBitmap(..) function as well. 00269 00270 */ 00271 // set bitmap size field so gets written out correctly 00272 pBitmapInfo->bmiHeader.biXPelsPerMeter = (INT32)((PixelsPerInch * 10000 ) / 254); 00273 //lpBitmapInfo->bmiHeader.biXPelsPerMeter = Mul32Div32( PixelsPerInch, 10000, 254 ); 00274 pBitmapInfo->bmiHeader.biYPelsPerMeter = pBitmapInfo->bmiHeader.biXPelsPerMeter; 00275 00276 // done OK 00277 return TRUE; 00278 }
|
|
DANGEROUS! Don't use this unless you really know what you're doing.
Definition at line 1451 of file grndbmp.cpp. 01452 { 01453 TRACEUSER( "Gerry", _T("GRenderBitmap::StopUsingGreyscaleContextDangerous\n")); 01454 ERROR3IF(pPreviousGDrawContext == NULL, "UseGreyscaleContextDangerous called while context not in use"); 01455 if (pPreviousGDrawContext != NULL) 01456 { 01457 if (SetTempDrawContext(pPreviousGDrawContext) != pGreyscaleContext) 01458 { 01459 ERROR3("Not pGreyscaleContext when restoring"); 01460 } 01461 pPreviousGDrawContext = NULL; 01462 } 01463 }
|
|
DANGEROUS! Don't use this unless you really know what you're doing.
This is currently used by the airbrush path stroking code to draw transparency information into an 8bpp greyscale bitmap, on the fly, during normal GDraw rendering. If you want to do something similar, take a look at that code, because great care must be taken when using one GRndRgn inside the other to make sure no corruption occurs. There is only one symptom of getting it wrong: a nasty access violation. Before calling StartRender on your new GRenderBitmap, call this function to install the new context. Once finished, you must restore the normal GRenderRegion state by calling StopUsingGreyscaleContextDangerous() Definition at line 1395 of file grndbmp.cpp. 01396 { 01397 TRACEUSER( "Gerry", _T("GRenderBitmap::UseGreyscaleContextDangerous\n")); 01398 ERROR3IF(pPreviousGDrawContext != NULL, "UseGreyscaleContextDangerous called while context in use"); 01399 if (pPreviousGDrawContext == NULL) 01400 { 01401 if (pGreyscaleContext == NULL) 01402 { 01403 PORTNOTE("other","GRenderBitmap::UseGreyscaleContextDangerous - removed progress reporting") 01404 #if !defined(EXCLUDE_FROM_XARALX) 01405 Progress::Start(); 01406 #endif 01407 01408 // Create a new context the first time anyone actually wants one 01409 pGreyscaleContext = new GDrawAsm; 01410 01411 if (pGreyscaleContext != NULL) 01412 { 01413 // pGreyscaleContext->Init(); 01414 01415 // And initialise the palette - this can unfortunately take a couple of seconds 01416 DWORD PaletteFlag = 0; 01417 if (WhichDither == 0 || WhichDither == 3) 01418 PaletteFlag = 1; 01419 01420 if (pGreyscaleContext->SelectPalette(PaletteFlag) != NULL) 01421 pGreyscaleContext->InitialiseWithPalette(pConvPalette); 01422 } 01423 01424 #if !defined(EXCLUDE_FROM_XARALX) 01425 Progress::Stop(); 01426 #endif 01427 } 01428 01429 if (pGreyscaleContext != NULL) 01430 { 01431 pPreviousGDrawContext = SetTempDrawContext(pGreyscaleContext); 01432 } 01433 } 01434 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|