grndprnt.cpp

Go to the documentation of this file.
00001 // $Id: wxOil/grndprnt.cpp, 1, 01-Jan-2006, Anonymous $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 // A GDraw render region for printing.
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "grndprnt.h"
00107 
00108 #include "colcontx.h"
00109 #include "colplate.h"
00110 #include "dibutil.h"
00111 #include "fixmem.h"
00112 #include "osrndrgn.h"
00113 #include "view.h"
00114 #include "oilbitmap.h"
00115 #include "psdc.h"
00116 #include "psrndrgn.h"
00117 
00118 CC_IMPLEMENT_DYNAMIC(GRenderPrint, GRenderDIB)
00119 
00120 DECLARE_SOURCE("$Revision: 3 $");
00121 
00122 // This will get Camelot to display the filename and linenumber of any memory allocations
00123 // that are not released at program exit
00124 #define new CAM_DEBUG_NEW
00125 
00126 
00127 /********************************************************************************************
00128 
00129 >   GRenderPrint::GRenderPrint(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, 
00130                                UINT32 Depth, double dpi)
00131 
00132     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00133     Created:    18/3/95
00134     Inputs:     -
00135     Purpose:    GRenderPrint constructor. Doesn't do anything actually, just calls base class.
00136                 INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed
00137                 at the < 1000dpi settings that we will be using.
00138     SeeAlso:    GRenderRegion::GRenderRegion
00139 
00140 ********************************************************************************************/
00141 
00142 GRenderPrint::GRenderPrint(DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, 
00143                            UINT32 Depth, double dpi)
00144     : GRenderDIB( ClipRegion, ConvertMatrix, ViewScale, Depth, dpi)
00145 {
00146     // If nobody has found us a sensible colour context yet, we'll just go for a global
00147     // default context
00148     if (CurrentColContext == NULL)
00149         CurrentColContext = ColourContext::GetGlobalDefault(COLOURMODEL_RGBT);
00150 
00151     // We are printing
00152     RenderFlags.Printing = TRUE;
00153 
00154     // We have not poked about in the RenderView's ColourPlates (yet)
00155     OldPlateDisabledState = FALSE;
00156     HaveDisabledPlate = FALSE;
00157 
00158     TRACEUSER( "Tim", _T("ClipRegion = (%ld, %ld), (%ld, %ld)\n"),
00159               ClipRegion.lo.x, ClipRegion.lo.y,
00160               ClipRegion.hi.x, ClipRegion.hi.y);
00161 }
00162 
00163 
00164 
00165 /********************************************************************************************
00166 
00167 >   virtual BOOL GRenderPrint::StartRender()
00168 
00169     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00170     Created:    18/3/95
00171     Returns:    TRUE if worked, FALSE if failed
00172 
00173     Purpose:    Calls GRenderDIB::StartRender
00174                 Initialises the bitmap to white (0xff)
00175                 Disables colour separation (this is done as a post-process on the
00176                 final bitmap in DisplayBits())
00177 
00178     SeeAlso:    GRenderDIB::StartRender
00179 
00180 ********************************************************************************************/
00181 
00182 BOOL GRenderPrint::StartRender()
00183 {
00184     // call base class first
00185     const BOOL ok = GRenderDIB::StartRender();
00186     if (!ok)
00187         return FALSE;
00188 
00189     // we need a white background, which on non-palette devices (all we can cope
00190     // with currently) is 0xFF a lot.
00191     memset( pBits, 0xFF, pBitmapInfo->bmiHeader.biSizeImage );
00192 
00193     // If we're colour separating then we want to DISABLE separations for the entire
00194     // rendering-to-a-bitmap process, and we will then colour separate the resultant
00195     // bitmap as it is output. We remember the previous ColourPlate disabled state
00196     // so that we can restore it in StopRender (well, in DisplayBits() in fact)
00197     ERROR3IF(RenderView != NULL && RenderView->GetColourPlate() != NULL &&
00198              HaveDisabledPlate && !RenderView->GetColourPlate()->IsDisabled(),
00199              "ColourPlate seems to have myseteriously become re-enabled in GRenderPrint");
00200     if (!HaveDisabledPlate && RenderView != NULL && RenderView->GetColourPlate() != NULL)
00201     {
00202         // We must disable all colour plates for colour contexts attached to this view.
00203         // We find all the currently cached contexts for this view, and disable their ColourPlates.
00204         // These will be re-enabled in StopRender. Note that we assume that nobody outside this
00205         // rendering loop will be disabling/enabling colour plates for specific contexts - they
00206         // should be setting the state more globally by changing the View's ColourPlate.
00207         // (We should be as well, with a proper access function in view to make this possible
00208         // but I'm being a bit lazy here. If you're reading this and swearing right now, then
00209         // I apologise for any incovenience caused)
00210         for (INT32 i = 0; i < MAX_COLOURMODELS; i++)
00211         {
00212             ColourContext *Bob = RenderView->GetColourContext((ColourModel) i, TRUE);
00213             if (Bob != NULL && Bob->GetColourPlate() != NULL)
00214                 Bob->GetColourPlate()->SetDisabled(TRUE);
00215         }
00216 
00217         // And poke the View's main ColourPlate (so that any new contexts created during
00218         // rendering use the new state)
00219         OldPlateDisabledState = RenderView->GetColourPlate()->IsDisabled();
00220         RenderView->GetColourPlate()->SetDisabled(TRUE);
00221 
00222         // Remember that we've poked at the ColourPlate so we can re-enable it in StopRender
00223         HaveDisabledPlate = TRUE;
00224     }
00225 
00226     // done OK
00227     return TRUE;
00228 }
00229 
00230 
00231 
00232 /********************************************************************************************
00233 
00234 >   virtual BOOL GRenderPrint::StopRender()
00235 
00236     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00237     Created:    8/7/96
00238     Returns:    TRUE if worked, FALSE if failed
00239     Purpose:    Stops rendering in this RR
00240                 Restores the ColourPlate separation options and calls GRenderDIB::StopRender
00241     SeeAlso:    GRenderDIB::StopRender
00242 
00243 ********************************************************************************************/
00244 
00245 BOOL GRenderPrint::StopRender()
00246 {
00247     // When colour separating we must restore the colour plate disabled state.
00248     // We assume that all contexts attached to the view should be using the same state as the
00249     // View's ColourPlate was, so we only store the one previous state for restoring from.
00250     if (HaveDisabledPlate && RenderView != NULL && RenderView->GetColourPlate() != NULL)
00251     {
00252         for (INT32 i = 0; i < MAX_COLOURMODELS; i++)
00253         {
00254             ColourContext *Bob = RenderView->GetColourContext((ColourModel) i, TRUE);
00255             if (Bob != NULL && Bob->GetColourPlate() != NULL)
00256                 Bob->GetColourPlate()->SetDisabled(OldPlateDisabledState);
00257         }
00258 
00259         // And restore the main View's ColourPlate
00260         RenderView->GetColourPlate()->SetDisabled(OldPlateDisabledState);
00261         OldPlateDisabledState = FALSE;
00262         HaveDisabledPlate = FALSE;
00263     }
00264 
00265     // call base class *last*
00266     return GRenderDIB::StopRender();
00267 }
00268 
00269 
00270 
00271 /********************************************************************************************
00272 
00273 >   GRenderPrint::~GRenderPrint()
00274 
00275     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00276     Created:    18/3/95
00277     Purpose:    GRenderPrint destructor. Frees up the bitmap.
00278 
00279 ********************************************************************************************/
00280 
00281 GRenderPrint::~GRenderPrint()
00282 {
00283     // we should NOT delete the CurrentColContext cos we didn't alloc it - we just
00284     // got a pointer to something allocated by somebody else
00285 
00286     // Free up the bitmap here, as the call to FreeLPBits in the
00287     // GRenderDIB will not call the correct version (the virtual-ness will be
00288     // broken as it is called from a destructor
00289     if (pBitmapInfo!=NULL)
00290     {
00291 //      FreeLPBits( pBitmapInfo, pBits );
00292         FreeOffscreenState();
00293         pBitmapInfo = NULL;
00294         pBits = NULL;
00295     }
00296 }
00297 
00298 
00299 
00300 /********************************************************************************************
00301 
00302 >   BOOL GRenderPrint::InitDevice()
00303 
00304     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00305     Created:    23/03/95
00306     Returns:    TRUE if initialised ok;
00307                 FALSE if not.
00308     Purpose:    Initialise the device specific mechanisms for this render region.
00309                 For a print region, it makes sure the StretchBlt mode is set up correctly
00310                 so we get half-toning.
00311     Errors:     Same as base class.
00312     SeeAlso:    RenderRegion::InitDevice; GRenderRegion::AttachDevice;
00313                 GRenderRegion::InitDevice
00314 
00315 ********************************************************************************************/
00316 
00317 BOOL GRenderPrint::InitDevice()
00318 {
00319     // Call the base class *first*
00320     BOOL Worked = GRenderDIB::InitDevice();
00321 
00322     if (!Worked)                              
00323         return FALSE;
00324 
00325     // if we don't do this, bitmaps printed at the same DPI as the printer come
00326     // out completely crap on NT drivers
00327     // Note: although this is claimed to be a Win32s-compatible function,
00328     // GDI16 generates an error for it (invalid value 4)
00329     // Note2: The MFC version of this function looks like the 16-bit API call,
00330     // so we call the API directly here.
00331 PORTNOTE("printing", "Don't SetStretchBltMode")
00332 #ifndef EXCLUDE_FROM_XARALX
00333     ::SetStretchBltMode(RenderDC->m_hDC, HALFTONE);
00334 #endif
00335 
00336     return TRUE;
00337 }
00338 
00339 
00340 
00341 /********************************************************************************************
00342 
00343 >   BOOL GRenderPrint::DisplayBits(LPBITMAPINFO lpDisplayBitmapInfo = NULL, LPBYTE lpDisplayBits = NULL)
00344 
00345     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00346     Created:    18/3/95
00347     Returns:    TRUE if worked, FALSE if failed.
00348     Purpose:    Output the bitmap in a printer-friendly way.
00349 
00350 ********************************************************************************************/
00351 
00352 BOOL GRenderPrint::DisplayBits(LPBITMAPINFO lpDisplayBitmapInfo, LPBYTE lpDisplayBits)
00353 {
00354 
00355     CCDC * pCCDC = CCDC::ConvertFromNativeDC(RenderDC);
00356     BOOL ToNativePS = (pCCDC->IsKindOf(CC_RUNTIME_CLASS(PSPrintDC)));
00357 
00358     if (ToNativePS)
00359     {
00360         // wxPostscriptDC does not really support stretched blitting of bitmaps. On a good day
00361         // when it works it scales the bitmap before outputting it, which means the PS is huge
00362         // So we get our native DC to do it.
00363 
00364         // Note that this colour corrects, and separates for us.
00365 
00366         // Set up a PrintPSRenderRegion with the same parameters
00367         PrintPSRenderRegion * pRender = new PrintPSRenderRegion(CurrentClipRect, RenderMatrix, ScaleFactor);
00368         ERROR2IF(!pRender, FALSE, "Cannot create PrintPSRenderRegion");
00369 
00370         // Try and create the bitmap etc
00371         if (!pRender->AttachDevice(RenderView, RenderDC, NULL) || !pRender->StartRender())
00372         {
00373             delete pRender;
00374             ERROR2(FALSE, "Cannot attach device or start rendering");
00375         }
00376 
00377 
00378         DocCoord Coords[4];
00379         Coords[0]=DocCoord(CurrentClipRect.lo.x, CurrentClipRect.hi.y);
00380         Coords[1]=CurrentClipRect.hi;
00381         Coords[2]=DocCoord(CurrentClipRect.hi.x, CurrentClipRect.lo.y);
00382         Coords[3]=CurrentClipRect.lo;
00383 
00384         // Handle rotation of the bitmap. The problem here is that the bitmap itself is always horizontally
00385         // oriented, so we need to make sure the rect we put it in is of the right orientation.
00386         ANGLE angle=0;
00387         RenderMatrix.Decompose(NULL, NULL, &angle);
00388         double dangle=angle.MakeDouble();
00389 
00390         if (dangle<0)
00391             dangle+=PI; // make angle positive
00392 
00393         while (dangle>PI/4) // we really mean >0, but allow for rounding. We know it's a multiple of 90.
00394         {
00395             // rotate the coordinate set used. Note we are not rotating the coordinates
00396             DocCoord save=Coords[3];
00397             Coords[3]=Coords[2];
00398             Coords[2]=Coords[1];
00399             Coords[1]=Coords[0];
00400             Coords[0]=save;
00401             dangle-=PI/2;
00402         }
00403 
00404         CWxBitmap oilbitmap(pBitmapInfo, pBits); // note this bitmap thinks it owns the bits and bitmap info
00405         pRender->DrawParallelogramBitmap(Coords, &oilbitmap);
00406         // now remove the bits and info so that the renderregion can delete them itself
00407         LPBYTE DummypBits=NULL;
00408         LPBITMAPINFO DummypBitmapInfo=NULL;
00409         oilbitmap.ExtractBitsAndInfo(&DummypBits, &DummypBitmapInfo);
00410 
00411         pRender->StopRender();
00412 
00413         delete pRender;
00414 
00415         return TRUE;
00416     }
00417 
00418     INT32 BitmapWidth = pBitmapInfo->bmiHeader.biWidth;
00419     INT32 BitmapHeight = pBitmapInfo->bmiHeader.biHeight;
00420 
00421     if (RenderView != NULL && RenderView->GetColourPlate() != NULL && 
00422         !RenderView->GetColourPlate()->IsDisabled())
00423     {
00424         // We currently can't handle anything less than 8bpp bitmaps here, as we
00425         // write the output data to our bitmap in 8bpp format.
00426         ERROR2IF(uBitmapDepth < 8, FALSE, "Unexpectedly low BPP in GRenderPrint::DisplayBits");
00427 
00428         // We're colour separating. We must separate the entire bitmap down to
00429         // an 8bpp greyscale format
00430         CWxBitmap Bitmap(pBitmapInfo, pBits);
00431 
00432         // We are doing a colour separation - find the separation tables
00433         BYTE *SepTables = NULL;
00434         ColourContextCMYK *cc = (ColourContextCMYK *)RenderView->GetColourContext(COLOURMODEL_CMYK);
00435         if (cc != NULL)
00436         {
00437             SepTables = (BYTE *) CCMalloc(5 * 256 * sizeof(BYTE));
00438             if (SepTables != NULL)
00439             {
00440                 if (!cc->GetProfileTables(SepTables))
00441                 {
00442                     CCFree(SepTables);
00443                     SepTables = NULL;
00444                 }
00445             }
00446         }
00447         ERROR2IF(SepTables == NULL, FALSE, "Can't generate separation tables in GRenderPrint::DisplayBits");
00448 
00449         ColourContext *OutputContext = RenderView->GetColourContext(COLOURMODEL_RGBT);
00450         ERROR2IF(OutputContext == NULL, FALSE, "No RGB rendering ColourContext in GRenderPrint::DisplayBits");
00451 
00452         // Get a temporary 32bpp scanline
00453         const INT32 PixelWidth  = Bitmap.GetWidth();
00454         const INT32 PixelHeight = Bitmap.GetHeight();
00455 
00456         const INT32 ByteWidth    = DIBUtil::ScanlineSize(PixelWidth, 8);    // Width of 8bit scanline including padding
00457 
00458         Pixel32bpp *TempScanline = (Pixel32bpp *) CCMalloc(PixelWidth * sizeof(Pixel32bpp));
00459         if (TempScanline == NULL)
00460         {
00461             ERROR3("No memory for temp scanline");
00462             return(FALSE);
00463         }
00464 
00465         BYTE *pOutputBuffer = pBits;                // We'll overwrite our bitmap with the separated data
00466         for (INT32 y = 0; y < PixelHeight; y++)
00467         {
00468             // Get this scanline as a 32bpp generic structure
00469             Bitmap.GetScanline32bpp(y, TRUE, TempScanline);
00470 
00471             Bitmap.ColourSeparateScanline32to8(OutputContext, SepTables, pOutputBuffer, TempScanline, PixelWidth);
00472             pOutputBuffer += ByteWidth;
00473         }
00474 
00475         // Make sure that the new 8bpp bitmap has a greyscale palette on it - if it was not 8bpp,
00476         // then we must realloc the header info to get enough room in it for a 256 colour palette.
00477         if (pBitmapInfo->bmiHeader.biBitCount != 8)
00478         {
00479             FreeDIB(pBitmapInfo, NULL, NULL, FALSE);                                // Free the info (ONLY)
00480             pBitmapInfo = AllocDIB(PixelWidth, PixelHeight, 8, NULL, NULL, FALSE);  // Realloc the info
00481         }
00482 
00483         // And fill in the palette to a greyscale
00484         for (INT32 i = 0; i < 256; i++)
00485         {
00486             pBitmapInfo->bmiColors[i].rgbRed = 
00487                 pBitmapInfo->bmiColors[i].rgbGreen = 
00488                     pBitmapInfo->bmiColors[i].rgbBlue = i;
00489 
00490             pBitmapInfo->bmiColors[i].rgbReserved = 0;
00491         }
00492 
00493         // Free our separation tables and temporary scanline
00494         CCFree(SepTables);
00495         CCFree(TempScanline);
00496 
00497         // Finally, poke the CWxBitmap we created so that it doesn't delete OUR
00498         // bitmap info and bytes (which we only lent it) when it is deleted
00499         Bitmap.BMInfo  = NULL;
00500         Bitmap.BMBytes = NULL;
00501     }
00502     else
00503     {
00504         // Not colour separating, but if it's a 32bpp bitmap, we need to convert to something 
00505         // that StretchDIBits (below) can understand
00506 PORTNOTE("printing", "Do not convert down BPP except under PS")
00507         if (ToNativePS && (uBitmapDepth == 32))
00508         {
00509             // Can't plot 32bpp bitmaps to GDI as 16-bit GDI doesn't understand them,
00510             // so we convert to 24bpp bitmap in-situ and render that...
00511 
00512             // How many bytes to a source scanline?
00513             const INT32 ScanlineBytes = DIBUtil::ScanlineSize(BitmapWidth, uBitmapDepth );
00514 
00515             // How many bytes to a destination scanline
00516             const INT32 DestlineBytes = DIBUtil::ScanlineSize(BitmapWidth, 24);
00517 
00518             // Now convert the bitmap in-situ
00519             LPBYTE OriginalBuffer  = pBits;
00520             LPBYTE ConvertedBuffer = pBits;
00521 
00522             for (INT32 i = 0; i < BitmapHeight; i++)
00523             {
00524                 DIBUtil::Convert32to24(BitmapWidth, OriginalBuffer, ConvertedBuffer);
00525                 OriginalBuffer += (UINT_PTR) ScanlineBytes;
00526                 ConvertedBuffer += (UINT_PTR) DestlineBytes;
00527             }
00528 
00529             // Update bitmap info to show it is now a 24bpp bitmap...
00530             pBitmapInfo->bmiHeader.biBitCount  = 24;
00531             pBitmapInfo->bmiHeader.biSizeImage = DestlineBytes * BitmapHeight;
00532         }
00533     }
00534 
00535     WinRect clip;
00536     //RenderDC->GetClipBox(&clip);
00537     clip = OSRenderRegion::DocRectToWin(RenderView, RenderMatrix, CurrentClipRect, 0, 0, 0, 0);
00538 
00539 PORTNOTE("printing", "Attempt to use StaticPlotBitmap instead of StretchDIBits")
00540 #ifndef EXCLUDE_FROM_XARALX
00541     INT32 Scanlines = StretchDIBits(RenderDC->m_hDC,
00542                                   clip.left, clip.top,
00543                                   clip.Width(), clip.Height(),
00544                                   0, 0,
00545                                   BitmapWidth, BitmapHeight,
00546                                   pBits,
00547                                   pBitmapInfo,
00548                                   DIB_RGB_COLORS,
00549                                   SRCCOPY);
00550 
00551     ERROR3IF(Scanlines == GDI_ERROR, "No scanlines copied in GRenderPrint::DisplayBits()!");
00552 #else
00553 
00554 
00555     // First of all get it into a bitmap we can understand
00556     wxBitmap Bitmap(BitmapWidth, BitmapHeight, 24);
00557     wxMemoryDC MemDC;
00558     MemDC.SelectObject(Bitmap);
00559     GRenderRegion::StaticPlotBitmap(&MemDC, DIB_RGB_COLORS, pBitmapInfo, pBits, 0, 0, BitmapWidth, BitmapHeight, NULL, 0, 0);
00560 
00561     //Bitmap.SaveFile(_T("/tmp/x.png"), wxBITMAP_TYPE_PNG);
00562 
00563     // Now blit this to the printer, stretching as appropriate
00564 #if 0
00565     RenderDC->Blit(clip.x, clip.y, clip.GetWidth(), clip.GetHeight(), &MemDC, 0, 0);
00566 #else
00567     INT32 fwidth = clip.GetWidth();
00568     INT32 fheight = clip.GetHeight();
00569     wxBitmap bitmap( (int)/* TYPENOTE: Correct */fwidth, (int)/* TYPENOTE: Correct */fheight, 24 );
00570     wxMemoryDC memDC;
00571     memDC.SelectObject(bitmap);
00572     memDC.Blit(0, 0, fwidth, fheight, &MemDC, 0, 0);
00573 
00574     //bitmap.SaveFile(_T("/tmp/y.png"), wxBITMAP_TYPE_PNG);
00575 
00576     RenderDC->DrawBitmap(bitmap, clip.x, clip.y);
00577 #endif
00578 #endif
00579 
00580     return TRUE;
00581 }
00582 
00583 
00584 
00585 /********************************************************************************************
00586 
00587 >   virtual BOOL GRenderPrint::SetFirstBand()
00588 
00589     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00590     Created:    5/5/95
00591     Returns:    TRUE 
00592     Purpose:    Sets up for banded rendering. This class does not do banded rendering as yet.
00593                 This just sets things up to indicate that everything will be done in one band.
00594 
00595 ********************************************************************************************/
00596 
00597 BOOL GRenderPrint::SetFirstBand()
00598 {
00599     // No Banding needed
00600     IsRegionBanded = FALSE;
00601     IsWaitingForRAM = FALSE;
00602     IsLastBand = TRUE;
00603     return TRUE;
00604 }
00605 
00606 
00607 
00608 /********************************************************************************************
00609 
00610 >   virtual BOOL GRenderPrint::GetNextBand()
00611 
00612     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00613     Created:    5/5/95
00614     Returns:    FALSE
00615     Purpose:    Since this class does not do banded rendering, there are never any more bands
00616 
00617 ********************************************************************************************/
00618 
00619 BOOL GRenderPrint::GetNextBand()
00620 {
00621     // No banding
00622     return FALSE;
00623 }
00624 
00625 
00626 
00627 /********************************************************************************************
00628 
00629 >   LPBITMAPINFO GRenderPrint::GetLPBits( INT32 Width, INT32 Height, INT32 Depth, LPBYTE*)
00630 
00631     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00632     Created:    5/5/95
00633     Inputs:     Width, Height - the width and height of the required bitmap
00634                 Depth - the bpp of the bitmap
00635     Returns:    Pointer to a bitmap header block
00636     Purpose:    Allocates a bitmap from the CCMalloc heap
00637 
00638 ********************************************************************************************/
00639 
00640 LPBITMAPINFO GRenderPrint::GetLPBits( INT32 Width, INT32 Height, INT32 Depth, LPBYTE* lplpBits)
00641 {
00642     // Get a DIB out of the CCMalloc heap
00643     LPBITMAPINFO bmInfo = NULL;
00644     bmInfo = AllocDIB( Width, Height, Depth, lplpBits, NULL, FALSE);
00645 
00646     // return it.
00647     return bmInfo;
00648 }
00649 
00650 
00651 
00652 
00653 /********************************************************************************************
00654 
00655 >   void GRenderPrint::FreeLPBits( LPBITMAPINFO, LPBYTE )
00656 
00657     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00658     Created:    5/5/95
00659     Purpose:    Frees the memory allocated in GetLPBits.
00660 
00661 ********************************************************************************************/
00662 
00663 void GRenderPrint::FreeLPBits( LPBITMAPINFO lpBMI, LPBYTE lpB )
00664 {
00665     // Free up the memory. Not from Limited Heap
00666     FreeDIB(lpBMI, lpB, NULL, FALSE);
00667 }

Generated on Sat Nov 10 03:48:33 2007 for Camelot by  doxygen 1.4.4