cdrbitm.cpp

Go to the documentation of this file.
00001 // $Id: cdrbitm.cpp 1282 2006-06-09 09:46:49Z alex $
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 // *********Bitmaps for the CDR file filter
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "cdrbitm.h"
00105 #include "cdrform.h"
00106 //#include "dibutil.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "wbitmap.h"
00108 #include "cdrfiltr.h"
00109 
00110 DECLARE_SOURCE("$Revision: 1282 $");
00111 
00112 #define new CAM_DEBUG_NEW
00113 
00114 // Note: As this is a winoil file, no use of the CDRDATA_* functions is made.
00115 // be aware of converting byte orders!
00116 
00117 #define PROGRESS_BLOCKSIZE 2048
00118 
00119 /********************************************************************************************
00120 
00121 >   static KernelBitmap *CDRBitmap::ConvertPattern(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00122 
00123     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    10/04/95
00125     Inputs:     RIFFFile with the chunk containing the pattern current, a pointer to the
00126                 reference number of this bitmap to fill in
00127     Returns:    a kernel bitmap or zero
00128     Purpose:    Convert a CDR pattern
00129     SeeAlso:    CDRFilter
00130 
00131 ********************************************************************************************/
00132 
00133 KernelBitmap *CDRBitmap::ConvertPattern(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00134 {
00135 TRACEUSER( "Ben", _T("Converting pattern\n"));
00136     // check various things
00137     ERROR3IF(RIFF->GetObjChunkType() != cdrT_bmpf, "ConvertPattern called for non-pattern RIFF chunk");
00138     ERROR3IF(RIFF->GetObjType() != RIFFOBJECTTYPE_CHUNK, "ConvertPattern called for a non-chunk RIFF object");
00139 
00140     if(RIFF->GetObjSize() < sizeof(cdrfPatternBitmapHeader))
00141     {
00142         // Empty 'if' statement
00143         // Anyone's guess if this was intended
00144         // Changed to this form to remove a compiler warning
00145         // Markn 19/3/99
00146     }
00147 
00148     // get some data from the RIFF file
00149     cdrfPatternBitmapHeader Hdr;
00150 
00151     // get the header from offset 0
00152     if(!RIFF->GetChunkData((ADDR)&Hdr, sizeof(Hdr), 0))
00153         return 0;
00154 
00155     // check the header...
00156     if(((Hdr.SizeX * Hdr.SizeY) / 8) > Hdr.DataSize || Hdr.DataSize > (DWORD)RIFF->GetObjSize())
00157     {
00158 TRACEUSER( "Ben", _T("Header in CDR pattern doesn't check out\n"));
00159         return 0;
00160     }
00161 
00162     // store the reference
00163 TRACEUSER( "Ben", _T("Pattern reference = %X\n"), Hdr.Reference);
00164     *Reference = Hdr.Reference;
00165 
00166     // OK, create a bitmap...
00167     // it's always a 1 bpp bitmap
00168     LPBYTE Image;
00169     LPBITMAPINFO ImageHeader;
00170     ImageHeader = AllocDIB(Hdr.SizeX, Hdr.SizeX, 1, &Image);
00171 
00172     if(ImageHeader == 0)
00173         return 0;
00174 
00175     // check and then fill in the image data
00176     if(ImageHeader->bmiHeader.biSizeImage < (Hdr.DataSize - (sizeof(DWORD) * 3)))
00177     {
00178         FreeDIB(ImageHeader, Image);
00179         return 0;
00180     }
00181 
00182     // set some palette data
00183     ImageHeader->bmiColors[0].rgbBlue = 0;
00184     ImageHeader->bmiColors[0].rgbGreen = 0;
00185     ImageHeader->bmiColors[0].rgbRed = 0;
00186     ImageHeader->bmiColors[0].rgbReserved = 0;
00187     ImageHeader->bmiColors[1].rgbBlue = 0xff;
00188     ImageHeader->bmiColors[1].rgbGreen = 0xff;
00189     ImageHeader->bmiColors[1].rgbRed = 0xff;
00190     ImageHeader->bmiColors[1].rgbReserved = 0;
00191 
00192     // corel bitmaps align the scanlines to the nearest byte, not the nearest word
00193     // how long is a corel scanline
00194     INT32 SourceScanlineLength = (Hdr.SizeX + 7)    / 8;
00195     
00196     // how long is the destination scanline?
00197     INT32 DestScanlineLength = ((Hdr.SizeX + 31) / 32) * 4;
00198 
00199     // sanity check
00200     ERROR3IF(DestScanlineLength < SourceScanlineLength, "Problem with scanline length calculations");
00201     
00202     // set up offsets of current line
00203     INT32 SourceOffset = Hdr.DataOffset + (sizeof(DWORD) * 3);
00204     INT32 DestOffset = ImageHeader->bmiHeader.biSizeImage - DestScanlineLength;
00205     
00206     // grab the image data, backwards
00207     INT32 Line;
00208     for(Line = 0; Line < (INT32)Hdr.SizeY; Line++)
00209     {
00210         if(!RIFF->GetChunkData(((ADDR)Image) + DestOffset,
00211                 SourceScanlineLength, SourceOffset))
00212         {
00213             FreeDIB(ImageHeader, Image);
00214             return 0;
00215         }
00216 
00217         SourceOffset += SourceScanlineLength;
00218         DestOffset -= DestScanlineLength;
00219 
00220         if((Line & 0xf) == 0)
00221             C->UpdateProgress(TRUE);
00222     }
00223 
00224     // OK, it's all filled in. Create a KernelBitmap from it.
00225     // first of all, get ourself a nice OIL bitmap
00226     WinBitmap *WinB = new WinBitmap(ImageHeader, Image);
00227 
00228     if(WinB == 0)
00229     {
00230         FreeDIB(ImageHeader, Image);
00231         return 0;
00232     }
00233 
00234     // and now get a KernelBitmap
00235     KernelBitmap *KerB = new KernelBitmap(WinB);
00236 
00237     if(KerB == 0)
00238     {
00239         delete WinB;
00240         return 0;
00241     }
00242 
00243     // and that's it for now, folks
00244     return KerB;
00245 }
00246 
00247 
00248 /********************************************************************************************
00249 
00250 >   static KernelBitmap *CDRBitmap::ConvertBitmap5(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00251 
00252     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00253     Created:    12/04/95
00254     Inputs:     RIFFFile with the chunk containing the bitmap current, a pointer to the
00255                 reference number of this bitmap to fill in
00256     Returns:    a kernel bitmap or zero
00257     Purpose:    Convert a CDR 5 bitmap
00258     SeeAlso:    CDRFilter
00259 
00260 ********************************************************************************************/
00261 
00262 KernelBitmap *CDRBitmap::ConvertBitmap5(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00263 {
00264     // check various things
00265     ERROR3IF(RIFF->GetObjChunkType() != cdrT_bmp, "ConvertBitmap called for non-bitmap RIFF chunk");
00266     ERROR3IF(RIFF->GetObjType() != RIFFOBJECTTYPE_CHUNK, "ConvertBitmap called for a non-chunk RIFF object");
00267 
00268     if(RIFF->GetObjSize() < sizeof(cdrfBitmapHeader))
00269     {
00270         // Empty 'if' statement
00271         // Anyone's guess if this was intended
00272         // Changed to this form to remove a compiler warning
00273         // Markn 19/3/99
00274     }
00275 
00276     // get some data from the RIFF file
00277     cdrfBitmapHeader Hdr;
00278 
00279     // get the header from offset 0
00280     if(!RIFF->GetChunkData((ADDR)&Hdr, sizeof(Hdr), 0))
00281         return 0;
00282 
00283     // check the header...
00284     UINT32 BitmapSize = DIBUtil::ScanlineSize( Hdr.SizeX, Hdr.Depth ) * Hdr.SizeY;
00285 
00286 //  if((((Hdr.SizeX * Hdr.SizeY) / Hdr.Depth) + Hdr.ImageOffset - cdrfBitmapHeaderImageOffsetCorrect)
00287 //                  > (DWORD)RIFF->GetObjSize()
00288 //                  || Hdr.Depth < 1 || Hdr.Depth > 32)
00289     if( (BitmapSize + Hdr.ImageOffset - cdrfBitmapHeaderImageOffsetCorrect)
00290                     > (DWORD)RIFF->GetObjSize()
00291                     || Hdr.Depth < 1 || Hdr.Depth > 32)
00292     {
00293 TRACEUSER( "Ben", _T("Header in CDR bitmap doesn't check out\n"));
00294         return 0;
00295     }
00296 
00297     // store the reference
00298 TRACEUSER( "Ben", _T("Bitmap reference = %X\n"), Hdr.Reference);
00299     *Reference = Hdr.Reference;
00300 
00301     // find a plausible number of palette entries...
00302     INT32 NPaletteEntries = Hdr.NPaletteEntries;
00303 
00304     if(NPaletteEntries > (1 << Hdr.Depth))
00305         NPaletteEntries = (1 << Hdr.Depth);
00306 
00307     if(NPaletteEntries < 0)
00308         NPaletteEntries = 0;    
00309 
00310     // is it a greyscale type bitmap?
00311     BOOL Greyscale = FALSE;
00312     if(Hdr.Depth <= 8 && Hdr.ImageType == cdrfBITMAPTYPE_GREYSCALE)
00313         Greyscale = TRUE;
00314 
00315     // OK, create a bitmap...
00316     LPBYTE Image;
00317     LPBITMAPINFO ImageHeader;
00318     ImageHeader = AllocDIB(Hdr.SizeX, Hdr.SizeY, Hdr.Depth, &Image);
00319 
00320     if(ImageHeader == 0)
00321         return 0;
00322 
00323     // right then, sort out that there palette if we really want to
00324     if(Hdr.Depth <= 8)
00325     {
00326         if(Greyscale)
00327         {   // it's a greyscale image - create a nice palette
00328             UINT32 Entries = 1 << Hdr.Depth;
00329             UINT32 Inc = 256 / Entries;
00330             UINT32 Value = 0;
00331             UINT32 l;
00332 
00333             for(l = 0; l < Entries; l++)
00334             {
00335                 ImageHeader->bmiColors[l].rgbRed = Value;
00336                 ImageHeader->bmiColors[l].rgbGreen = Value;
00337                 ImageHeader->bmiColors[l].rgbBlue = Value;
00338                 ImageHeader->bmiColors[l].rgbReserved = 0;
00339 
00340                 Value += Inc;
00341             }
00342         }
00343         else
00344         {   // it's a colour image - load it's palette from the file
00345             // load the palette data into the palette in the created bitmap
00346             if(!RIFF->GetChunkData((ADDR)ImageHeader->bmiColors,
00347                     sizeof(cdrfBitmapPaletteEntry) * NPaletteEntries, sizeof(cdrfBitmapHeader)))
00348             {
00349                 FreeDIB(ImageHeader, Image);
00350                 return 0;
00351             }
00352 
00353             // run through the loaded entries expanding them to DIB entries
00354             INT32 l;
00355             cdrfBitmapPaletteEntry *Palette = (cdrfBitmapPaletteEntry *)ImageHeader->bmiColors;
00356             cdrfBitmapPaletteEntry TempCol;
00357             for(l = NPaletteEntries - 1; l >= 0; l--)
00358             {
00359                 TempCol = Palette[l];
00360                 ImageHeader->bmiColors[l].rgbRed = TempCol.Red;
00361                 ImageHeader->bmiColors[l].rgbGreen = TempCol.Green;
00362                 ImageHeader->bmiColors[l].rgbBlue = TempCol.Blue;
00363                 ImageHeader->bmiColors[l].rgbReserved = 0;
00364             }
00365 
00366             if (Hdr.Depth == 1)
00367             {
00368                 // Ensure the palette entries are not the same!
00369                 if (ImageHeader->bmiColors[0].rgbRed == ImageHeader->bmiColors[1].rgbRed &&
00370                     ImageHeader->bmiColors[0].rgbGreen == ImageHeader->bmiColors[1].rgbGreen &&
00371                     ImageHeader->bmiColors[0].rgbBlue == ImageHeader->bmiColors[1].rgbBlue)
00372                 {
00373                     ImageHeader->bmiColors[0].rgbRed = 0x00;
00374                     ImageHeader->bmiColors[0].rgbGreen = 0x00;
00375                     ImageHeader->bmiColors[0].rgbBlue = 0x00;
00376 
00377                     ImageHeader->bmiColors[1].rgbRed = 0xff;
00378                     ImageHeader->bmiColors[1].rgbGreen = 0xff;
00379                     ImageHeader->bmiColors[1].rgbBlue = 0xff;
00380                 }
00381             }
00382         }
00383     }
00384 
00385     // work out the scanline lengths (aligns to 4 bytes)
00386     INT32 RawScanlineLength = Hdr.SizeX * Hdr.Depth;    // in bits
00387     INT32 ScanlineLength = DIBUtil::ScanlineSize( Hdr.SizeX, Hdr.Depth ); // in bytes 
00388     //INT32 ScanlineLength = ((RawScanlineLength + 31) / 32) * 4;
00389 
00390     // set up offsets of current line
00391     INT32 SourceOffset;
00392     
00393     if(Greyscale)
00394     {
00395         SourceOffset = cdrfBitmapGreyscaleImageStart;
00396     }
00397     else
00398     {
00399         SourceOffset = sizeof(cdrfBitmapHeader) + Hdr.ImageOffset - cdrfBitmapHeaderImageOffsetCorrect;
00400     }
00401 
00402     // grab the image data, it's in the same sort of format as a DIB file. Helpfully
00403     INT32 SizeLeftToGet = ScanlineLength * Hdr.SizeY;
00404     INT32 Size, Got = 0;
00405 
00406     while(SizeLeftToGet > 0)
00407     {
00408         if(SizeLeftToGet > PROGRESS_BLOCKSIZE)
00409             Size = PROGRESS_BLOCKSIZE;
00410         else
00411             Size = SizeLeftToGet;
00412         
00413         if(!RIFF->GetChunkData((ADDR)Image + Got, Size, SourceOffset + Got))
00414         {
00415             FreeDIB(ImageHeader, Image);
00416             return 0;
00417         }
00418     
00419         SizeLeftToGet -= Size;
00420         Got += Size;
00421 
00422         C->UpdateProgress(TRUE);
00423     }
00424 
00425     // OK, it's all filled in. Create a KernelBitmap from it.
00426     // first of all, get ourself a nice OIL bitmap
00427     WinBitmap *WinB = new WinBitmap(ImageHeader, Image);
00428 
00429     if(WinB == 0)
00430     {
00431         FreeDIB(ImageHeader, Image);
00432         return 0;
00433     }
00434 
00435     // get it to cache some interesting stuff
00436     WinB->CacheGeometry();
00437 
00438     // and now get a KernelBitmap
00439     KernelBitmap *KerB = new KernelBitmap(WinB);
00440 
00441     if(KerB == 0)
00442     {
00443         delete WinB;
00444         return 0;
00445     }
00446 
00447     // and that's it for now, folks
00448     return KerB;
00449 }
00450 
00451 
00452 /********************************************************************************************
00453 
00454 >   static KernelBitmap *CDRBitmap::ConvertBitmap4(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00455 
00456     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00457     Created:    12/04/95
00458     Inputs:     RIFFFile with the chunk containing the bitmap current, a pointer to the
00459                 reference number of this bitmap to fill in
00460     Returns:    a kernel bitmap or zero
00461     Purpose:    Convert a CDR 4 bitmap
00462     SeeAlso:    CDRFilter
00463 
00464 ********************************************************************************************/
00465 
00466 KernelBitmap *CDRBitmap::ConvertBitmap4(RIFFFile *RIFF, DWORD *Reference, CDRFilter *C)
00467 {
00468     // check various things
00469     ERROR3IF(RIFF->GetObjChunkType() != cdrT_bmp, "ConvertBitmap called for non-bitmap RIFF chunk");
00470     ERROR3IF(RIFF->GetObjType() != RIFFOBJECTTYPE_CHUNK, "ConvertBitmap called for a non-chunk RIFF object");
00471 
00472     if(RIFF->GetObjSize() < sizeof(cdrfBitmapHeader4))
00473     {
00474         // Empty 'if' statement
00475         // Anyone's guess if this was intended
00476         // Changed to this form to remove a compiler warning
00477         // Markn 19/3/99
00478     }
00479 
00480     // get some data from the RIFF file
00481     cdrfBitmapHeader4 Hdr;
00482 
00483     // get the header from offset 0
00484     if(!RIFF->GetChunkData((ADDR)&Hdr, sizeof(Hdr), 0))
00485         return 0;
00486 
00487     // check the header...
00488     if((((Hdr.SizeX * Hdr.SizeY) / Hdr.Depth) + Hdr.ImageOffset - cdrfBitmapHeaderImageOffsetCorrect)
00489                     > (DWORD)RIFF->GetObjSize()
00490                     || Hdr.Depth < 1 || Hdr.Depth > 32)
00491     {
00492 TRACEUSER( "Ben", _T("Header in CDR bitmap doesn't check out\n"));
00493         return 0;
00494     }
00495 
00496     // store the reference
00497 TRACEUSER( "Ben", _T("Bitmap reference = %X\n"), Hdr.Reference);
00498     *Reference = Hdr.Reference;
00499 
00500     // find a plausible number of palette entries...
00501     INT32 NPaletteEntries = Hdr.NPaletteEntries;
00502 
00503     if(NPaletteEntries > (1 << Hdr.Depth))
00504         NPaletteEntries = (1 << Hdr.Depth);
00505 
00506     if(NPaletteEntries < 0)
00507         NPaletteEntries = 0;    
00508 
00509     // is it a greyscale type bitmap?
00510     BOOL Greyscale = FALSE;
00511 //  if(Hdr.Depth <= 8 && Hdr.ImageType == cdrfBITMAPTYPE_GREYSCALE)
00512 //      Greyscale = TRUE;
00513 
00514     // OK, create a bitmap...
00515     LPBYTE Image;
00516     LPBITMAPINFO ImageHeader;
00517     ImageHeader = AllocDIB(Hdr.SizeX, Hdr.SizeY, Hdr.Depth, &Image);
00518 
00519     if(ImageHeader == 0)
00520         return 0;
00521 
00522     // right then, sort out that there palette if we really want to
00523     if(Hdr.Depth <= 8)
00524     {
00525         if(Greyscale)
00526         {   // it's a greyscale image - create a nice palette
00527             UINT32 Entries = 1 << Hdr.Depth;
00528             UINT32 Inc = 256 / Entries;
00529             UINT32 Value = 0;
00530             UINT32 l;
00531 
00532             for(l = 0; l < Entries; l++)
00533             {
00534                 ImageHeader->bmiColors[l].rgbRed = Value;
00535                 ImageHeader->bmiColors[l].rgbGreen = Value;
00536                 ImageHeader->bmiColors[l].rgbBlue = Value;
00537                 ImageHeader->bmiColors[l].rgbReserved = 0;
00538 
00539                 Value += Inc;
00540             }
00541         }
00542         else
00543         {   // it's a colour image - load it's palette from the file
00544             // load the palette data into the palette in the created bitmap
00545             if(!RIFF->GetChunkData((ADDR)ImageHeader->bmiColors,
00546                     sizeof(cdrfBitmapPaletteEntry4) * NPaletteEntries, sizeof(cdrfBitmapHeader4)))
00547             {
00548                 FreeDIB(ImageHeader, Image);
00549                 return 0;
00550             }
00551         }
00552     }
00553 
00554     // work out the scanline lengths (aligns to 4 bytes)
00555     INT32 RawScanlineLength = Hdr.SizeX * Hdr.Depth;    // in bits
00556     INT32 ScanlineLength = ((RawScanlineLength + 31) / 32) * 4;
00557 
00558     // set up offsets of current line
00559     INT32 SourceOffset;
00560     
00561     if(Greyscale)
00562     {
00563         SourceOffset = cdrfBitmapGreyscaleImageStart;
00564     }
00565     else
00566     {
00567         SourceOffset = sizeof(cdrfBitmapHeader) + Hdr.ImageOffset - cdrfBitmapHeaderImageOffsetCorrect;
00568     }
00569 
00570     // grab the image data, it's in the same sort of format as a DIB file. Helpfully
00571 //  if(!RIFF->GetChunkData((ADDR)Image, ScanlineLength * Hdr.SizeY, SourceOffset))
00572 //  {
00573 //      FreeDIB(ImageHeader, Image);
00574 //      return 0;
00575 //  }
00576     INT32 SizeLeftToGet = ScanlineLength * Hdr.SizeY;
00577     INT32 Size, Got = 0;
00578 
00579     while(SizeLeftToGet > 0)
00580     {
00581         if(SizeLeftToGet > PROGRESS_BLOCKSIZE)
00582             Size = PROGRESS_BLOCKSIZE;
00583         else
00584             Size = SizeLeftToGet;
00585         
00586         if(!RIFF->GetChunkData((ADDR)Image + Got, Size, SourceOffset + Got))
00587         {
00588             FreeDIB(ImageHeader, Image);
00589             return 0;
00590         }
00591     
00592         SizeLeftToGet -= Size;
00593         Got += Size;
00594 
00595         C->UpdateProgress(TRUE);
00596     }
00597 
00598     // OK, it's all filled in. Create a KernelBitmap from it.
00599     // first of all, get ourself a nice OIL bitmap
00600     WinBitmap *WinB = new WinBitmap(ImageHeader, Image);
00601 
00602     if(WinB == 0)
00603     {
00604         FreeDIB(ImageHeader, Image);
00605         return 0;
00606     }
00607 
00608     // get it to cache some interesting stuff
00609     WinB->CacheGeometry();
00610 
00611     // and now get a KernelBitmap
00612     KernelBitmap *KerB = new KernelBitmap(WinB);
00613 
00614     if(KerB == 0)
00615     {
00616         delete WinB;
00617         return 0;
00618     }
00619 
00620     // and that's it for now, folks
00621     return KerB;
00622 }
00623 
00624 
00625 
00626 /********************************************************************************************
00627 
00628 >   static KernelBitmap *GenerateBitmap(Node *Objects, DocRect *BBox, Document *pDocument)
00629 
00630     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00631     Created:    17/05/95
00632     Inputs:     pointer to some objects, a bounding box to render, and a document to use
00633                 the default attributes of
00634     Returns:    a kernel bitmap or zero
00635     Purpose:    Generate a bitmap of some objects.
00636     SeeAlso:    CDRFilter
00637 
00638 ********************************************************************************************/
00639 
00640 KernelBitmap *GenerateBitmap(Node *Objects, DocRect *BBox, Document *pDocument)
00641 {
00642     return 0;
00643 }
00644 
00645 
00646 
00647 
00648 
00649 
00650 

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