CBMPBits Class Reference

Converts & removes Solid on Black 32bit problems! More...

#include <mrhbits.h>

List of all members.

Static Public Member Functions

static OILBitmapRenderOILBMPToTransparentWhiteRect (OILBitmap *pConvBMP=NULL, BOOL Transparent=TRUE, INT32 OutputBPP=32)
 Front end function for RenderBMPFillAttrToTransparentWhiteRect(BitmapFillAttribute* pRef) used if the calling function does not contain a bitmapfillattribute!
static OILBitmapRenderKernelBMPToTransparentWhiteRect (KernelBitmap *pConvBMP=NULL, BOOL Transparent=TRUE, INT32 OutputBPP=32)
 Front end function for RenderBMPFillAttrToTransparentWhiteRect(BitmapFillAttribute* pRef) used if the calling function does not contain a bitmapfillattribute!
static OILBitmapRenderBMPFillAttrToTransparentWhiteRect (BitmapFillAttribute *pRef=NULL, BOOL Transparent=TRUE, INT32 OutputBPP=32)
 Renders a Any Bitmap onto a 32bit Transparent White Rectangle of size equal to bitmap referenced. This is mainly used just before a 32bit alpha channeled bitmap is rendered into a lower dpi region. It stops the effect of rendering solid shapes on a black background.
static OILBitmapRenderSelectionToBMP (SelRange *pSel=NULL, INT32 OutputBPP=32, BOOL Transparent=TRUE, DocRect *pClip=NULL, double DPI=96.0)
 Renders any selection of nodes into a BMP copy.

Private Member Functions

 CC_DECLARE_MEMDUMP (CBMPBits)


Detailed Description

Converts & removes Solid on Black 32bit problems!

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> H
Date:
2/8/99

Definition at line 115 of file mrhbits.h.


Member Function Documentation

CBMPBits::CC_DECLARE_MEMDUMP CBMPBits   )  [private]
 

OILBitmap * CBMPBits::RenderBMPFillAttrToTransparentWhiteRect BitmapFillAttribute pRef = NULL,
BOOL  Transparent = TRUE,
INT32  OutputBPP = 32
[static]
 

Renders a Any Bitmap onto a 32bit Transparent White Rectangle of size equal to bitmap referenced. This is mainly used just before a 32bit alpha channeled bitmap is rendered into a lower dpi region. It stops the effect of rendering solid shapes on a black background.

Author:
Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/7/99
Parameters:
A Pointer to a Bitmap Reference, Flag to say wether or not the Rectangle is to be transparent! [INPUTS]
None [OUTPUTS]
Returns:
TRUE if Everything ok!

Definition at line 233 of file mrhbits.cpp.

00234 {
00235     ERROR2IF(pRef == NULL, FALSE, "Where`s the Bitmap Reference Pointer? {DIBUtil}");
00236 
00237     // Ok, we`ve got a 32Bit BMP so lets setup a render region!
00238     View*   pView = View::GetCurrent();
00239     Matrix  Mat(1,0,0,1,0,0);
00240     FIXED16 Scale = 1;
00241     double  DPI = 96;
00242     DocRect RenderRect;
00243     OILBitmap* pNewBMP = NULL;
00244 
00245     // Get the info from the bitmap we`re trying to display in the gallery!
00246 //  LPBITMAPINFOHEADER pInfo = (pRef->GetBitmap()->ActualBitmap)->GetBitmapInfoHeader();
00247 
00248     // Setup the DocRect with the Start and End points of the bitmap fill
00249     RenderRect.lo.x = pRef->GetStartPoint()->x;
00250     RenderRect.lo.y = pRef->GetStartPoint()->y;
00251     RenderRect.hi.x = pRef->GetEndPoint()->x;
00252     RenderRect.hi.y = pRef->GetEndPoint2()->y;
00253 
00254     // Create a new GRenderBitmap region
00255     GRenderBitmap* pGBMP = new GRenderBitmap(RenderRect, Mat, Scale, OutputBPP, DPI, FALSE, 0, NULL, TRUE);
00256 
00257     if(pGBMP != NULL && pView != NULL)
00258     {
00259         // Set the flag to say that we want to use the BiCompression Field for transparencies!
00260         pGBMP->m_DoCompression = TRUE;
00261         
00262         // Create a new path which is the same size as the bitmap which will fill it!
00263         Path BMPPath;
00264         BMPPath.Initialise();
00265         BMPPath.CreatePathFromDocRect(&RenderRect);
00266 
00267         // Create a new FlatFillAttr and set it to white
00268         FlatFillAttribute* pWhiteFill = new FlatFillAttribute;
00269         DocColour White(COLOUR_WHITE);
00270         pWhiteFill->SetStartColour(&White);
00271 
00272         // Create a new StrokeColourAttr and set that also to white
00273         StrokeColourAttribute* pStrokeColour = new StrokeColourAttribute;
00274         pStrokeColour->SetStartColour(&White);
00275 
00276         // Create a new stroketransattr and set it to fully transparent
00277         StrokeTranspAttribute* pStrokeTrans = NULL;
00278         FlatTranspFillAttribute* pTransFill = NULL;
00279 
00280         if(Transparent)
00281         {
00282             pStrokeTrans = new StrokeTranspAttribute(0xFF);
00283             pTransFill = new FlatTranspFillAttribute(0xFF);
00284         }
00285         else
00286         {
00287             pStrokeTrans = new StrokeTranspAttribute(0x00);
00288             pTransFill = new FlatTranspFillAttribute(0x00);
00289         }
00290 
00291         // Make sure everything got setup alright and then proceed!
00292         if( pWhiteFill != NULL && pStrokeColour != NULL &&
00293             pStrokeTrans != NULL && pTransFill != NULL)
00294         {
00295             if (!pGBMP->AttachDevice(pView, NULL, NULL))
00296             {
00297                 ERROR3("Cannot attatch devices");
00298             }
00299 
00300             // Initialize the Render region
00301             pGBMP->InitDevice();
00302 
00303             // Save the current context
00304             pGBMP->SaveContext();
00305 
00306             // Start the render process
00307             pGBMP->StartRender();
00308 
00309             pGBMP->SetLineColour(COLOUR_NONE);
00310             pGBMP->SetLineWidth(0);
00311 
00312             // Set all the attributes we`ve just created
00313             pTransFill->Render(pGBMP);
00314             pStrokeTrans->Render(pGBMP);
00315             pWhiteFill->Render(pGBMP);
00316             pStrokeColour->Render(pGBMP);
00317 
00318             // Render a rectangle with the current attributes
00319             pGBMP->DrawRect(&RenderRect);
00320 
00321             // Now Render the Bitmap using no Flat Transparency, else it all comes out blank!           
00322             UINT32 NoTrans = 0x00;
00323             pTransFill->SetStartTransp(&NoTrans);
00324             pTransFill->Render(pGBMP);
00325 
00326             // Render the bitmap onto the white rectangle
00327             pGBMP->RenderBitmapFill(&BMPPath,pRef);
00328 
00329             // Finished so stop rendering
00330             pGBMP->StopRender();
00331 
00332             // Restore the old context
00333             pGBMP->RestoreContext();
00334 
00335             // WinBM Now needs to be setup with the newly created bitmap
00336             pNewBMP = OILBitmap::Attach(pGBMP->ExtractBitmapCopy(),TRUE);
00337         }
00338         else
00339         {
00340             ERROR3("Can not display 32bit Alpha channel bitmap!!!");
00341         }
00342 
00343         // Now delete everything!
00344         if(pGBMP != NULL)
00345         {
00346             delete pGBMP;
00347             pGBMP = NULL;
00348         }
00349 
00350         if(pStrokeColour != NULL)
00351         {
00352             delete pStrokeColour;
00353             pStrokeColour = NULL;
00354         }
00355 
00356         if(pStrokeTrans != NULL)
00357         {
00358             delete pStrokeTrans;
00359             pStrokeTrans = NULL;
00360         }
00361 
00362         if(pWhiteFill != NULL)
00363         {
00364             delete pWhiteFill;
00365             pWhiteFill = NULL;
00366         }
00367 
00368         if(pTransFill != NULL)
00369         {
00370             delete pTransFill;
00371             pTransFill = NULL;
00372         }
00373     }
00374 
00375     // Return the new Bitmap!
00376     return pNewBMP;
00377 }

OILBitmap * CBMPBits::RenderKernelBMPToTransparentWhiteRect KernelBitmap pConvBMP = NULL,
BOOL  Transparent = TRUE,
INT32  OutputBPP = 32
[static]
 

Front end function for RenderBMPFillAttrToTransparentWhiteRect(BitmapFillAttribute* pRef) used if the calling function does not contain a bitmapfillattribute!

Author:
Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/7/99
Parameters:
Pointer to an KernelBitmap, Flag to say wether or not the Rectangle is to be transparent! [INPUTS]
None [OUTPUTS]
Returns:
TRUE if Everything ok!

Definition at line 168 of file mrhbits.cpp.

00169 {
00170     // Check to see if we`ve been given a null bitmap pointer!
00171     ERROR2IF(pConvBMP == NULL,FALSE,"We`ve got a NULL Bitmap Pointer!! CBMPBits!");
00172 
00173     // Setup All the pointers that are going to be used
00174     OILBitmap* pNewBMP = NULL;
00175     BitmapFillAttribute* pRef = NULL;
00176 
00177     // Create the new BitmapFill Attribute
00178     pRef = new BitmapFillAttribute;
00179 
00180     if(pRef != NULL)
00181     {
00182         // make it reference the Passed in OILBitmap!
00183         pRef->AttachBitmap(pConvBMP);
00184 
00185         // Get the Width and Height of the Bitmap
00186         UINT32 Width = pConvBMP->GetWidth();
00187         UINT32 Height = pConvBMP->GetHeight();
00188 
00189         // Set the Fill Coordinates from the width and height variables
00190         DocCoord Start(0, 0);
00191         DocCoord End(Width * 750, 0);
00192         DocCoord End2(0, Height * 750);
00193 
00194         pRef->SetStartPoint(&Start);
00195         pRef->SetEndPoint(&End);
00196         pRef->SetEndPoint2(&End2);
00197 
00198         // Set the tessalation to repeating
00199         pRef->SetTesselation(2);
00200 
00201         // Now call the RenderBMPFillAttrToTransparentWhiteRect function with our new
00202         // BitmapFillAttribute!
00203         pNewBMP = RenderBMPFillAttrToTransparentWhiteRect(pRef,Transparent,OutputBPP);
00204     }
00205 
00206     // Delete everything that we created!
00207     if(pRef != NULL)
00208     {
00209         pRef->DetachBitmap();
00210         delete pRef;
00211         pRef = NULL;
00212     }
00213 
00214     // Return the new Bitmap
00215     return pNewBMP;
00216 }

OILBitmap * CBMPBits::RenderOILBMPToTransparentWhiteRect OILBitmap pConvBMP = NULL,
BOOL  Transparent = TRUE,
INT32  OutputBPP = 32
[static]
 

Front end function for RenderBMPFillAttrToTransparentWhiteRect(BitmapFillAttribute* pRef) used if the calling function does not contain a bitmapfillattribute!

Author:
Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/7/99
Parameters:
Pointer to an OILBitmap, Flag to say wether or not the Rectangle is to be transparent! [INPUTS]
None [OUTPUTS]
Returns:
TRUE if Everything ok!

Definition at line 131 of file mrhbits.cpp.

00132 {
00133     // Check to see if we`ve been given a null bitmap pointer!
00134     ERROR2IF(pConvBMP == NULL,FALSE,"We`ve got a NULL Bitmap Pointer!! CBMPBits!");
00135 
00136     // Setup All the pointers that are going to be used
00137     KernelBitmap* pKernel = NULL;
00138     OILBitmap* pNewBMP = NULL;
00139 
00140     // Create a new KernelBitmap from the OILBitmap so we can create a new BitmapFillAttribute!
00141     pKernel = new KernelBitmap(pConvBMP);
00142     
00143     if(pKernel != NULL)
00144     {
00145         pNewBMP = RenderKernelBMPToTransparentWhiteRect(pKernel, Transparent, OutputBPP);
00146 
00147         delete pKernel;
00148         pKernel = NULL;
00149     }
00150 
00151     // Return the new Bitmap
00152     return pNewBMP;
00153 }

OILBitmap * CBMPBits::RenderSelectionToBMP SelRange pSel = NULL,
INT32  OutputBPP = 32,
BOOL  Transparent = TRUE,
DocRect pClip = NULL,
double  DPI = 96.0
[static]
 

Renders any selection of nodes into a BMP copy.

Author:
Mark_Howitt (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/99
Parameters:
Flag to say wether or not the Rectangle is to be transparent and the required [INPUTS] output depth. Pointer to the current selection of nodes.
Returns:
The newly rendered BMP or NULL if something went bang!

Definition at line 391 of file mrhbits.cpp.

00392 {
00393     // Check to see if we have a valid selection pointer!
00394     ERROR2IF(pSel == NULL,NULL,"Recieved a NULL Selection Range Pointer in CBMPBits!");
00395 
00396     // Ok, Lets setup a few variables need to create the new BMP
00397     View*   pView = View::GetCurrent();
00398     Matrix  Mat(1,0,0,1,0,0);
00399     FIXED16 Scale = 1;
00400 //  double  DPI = 96;
00401     OILBitmap* pNewBMP = NULL;
00402 
00403     // Get the current DocRect of the selection!
00404     // but use the passed in clip region if it is already calculated
00405     DocRect RenderRect = pClip ? *pClip : pSel->GetBoundingRect();
00406 
00407     // Check to see if we`ve got an empty rect if so then return NULL!
00408     ERROR2IF(RenderRect.IsEmpty(),NULL,"We`ve got an empty DocRect in the selection! (CBMPBits)");
00409 
00410     // Create a new GRenderBitmap region
00411     GRenderBitmap* pGBMP = new GRenderBitmap(RenderRect, Mat, Scale, OutputBPP, DPI, FALSE, 0, NULL, TRUE);
00412 
00413     // Check to see if the Render Region is valid!
00414     ERROR2IF(pGBMP == NULL,NULL,"Failed to create a GRenderBitmap in CBMPBits!");
00415 
00416     if (Transparent)
00417     {
00418         // Set the flag to say that we want to use the BiCompression Field for transparencies!
00419         pGBMP->m_DoCompression = TRUE;
00420     }
00421 
00422     // Start to render into region!
00423     if(!pGBMP->AttachDevice(pView, NULL, NULL))
00424     {
00425         ERROR3("Cannot attatch devices");
00426         
00427         delete pGBMP;
00428         pGBMP = NULL;
00429         
00430         return NULL;
00431     }
00432 
00433     pGBMP->InitDevice();
00434     pGBMP->InitAttributes();
00435     pGBMP->RRQuality.SetQuality(QUALITY_MAX);
00436     pGBMP->SetQualityLevel();
00437     pGBMP->SetLineAttributes();
00438     pGBMP->SetFillAttributes();
00439 
00440     pGBMP->StartRender();
00441 
00442     Node* pCurrent = pSel->FindFirst(FALSE);
00443 
00444     while(pCurrent != NULL)
00445     {
00446         // Render all it's child nodes using the following function
00447         pGBMP->RenderTreeNoCache(pCurrent);
00448 
00449         pCurrent = pSel->FindNext(pCurrent);
00450     }
00451 
00452     // Rendered everything so stop the render process.
00453     pGBMP->StopRender();
00454 
00455     // Now Extract the bitmap!
00456     pNewBMP = OILBitmap::Attach(pGBMP->ExtractBitmapCopy(),TRUE);
00457 
00458     // Delete all the new`s that have happened!
00459     if(pGBMP != NULL)
00460     {
00461         delete pGBMP;
00462         pGBMP = NULL;
00463     }
00464     
00465     // If everything went ok then return the pointer to the BMP!
00466     return pNewBMP;
00467 }


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