bitmap.h

Go to the documentation of this file.
00001 // $Id: bitmap.h 1708 2006-08-17 17:13:38Z gerry $
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 // kernel class to encompass bitmaps
00100 
00101 #ifndef INC_BITMAP
00102 #define INC_BITMAP
00103 
00104 #include "listitem.h"
00105 #include "doccolor.h"
00106 #include "gradtype.h"
00107 #include "doccomp.h"
00108 //#include "gifutil.h"
00109 #include "outptgif.h"
00110 //#include "xmlutils.h"
00111 #include "dibutil.h"
00112 
00113 class OILBitmap;
00114 class KernelBitmapRef;
00115 class BitmapInfo;
00116 class RenderRegion;
00117 class Filter;
00118 class FillGeometryAttribute;
00119 class BitmapList;
00120 class Document;
00121 class BaseBitmapFilter;
00122 class BaseCamelotFilter;
00123 class CCLexFile;
00124 class View;
00125 class BitmapSource;
00126 class MaskedFilter;
00127 
00128 /*********************************************************************************************
00129 
00130 >   struct Pixel32bpp
00131 
00132     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00133     Created:    3/7/96
00134     Purpose:    This structure defines the layout of a 32bpp RGB pixel value, in a nice kernel
00135                 compatible way. They should be used for kernel access to bitmaps so that
00136                 pixels are treated in a platform independent manner.
00137 
00138                 The definitions of these pixels are such that a scanline of pixels is a
00139                 packed array of bytes like this:
00140                     Red0 Green0 Blue0 Alpha0 Red1 Green1 Blue1 Alpha1 Red2 Green2 Blue2 Alpha2...
00141 
00142                 When not using the Alpha channel, set its value to 0.
00143 
00144     SeeAlso:    OILBtmap::GetScanline32; OILBtmap::PlotPixel; OILBtmap::ReadPixel
00145 
00146 **********************************************************************************************/ 
00147 
00148 typedef struct
00149 {
00150     BYTE Red;
00151     BYTE Green;
00152     BYTE Blue;
00153     BYTE Alpha;
00154 } Pixel32bpp;
00155 
00156 
00157 
00158 /*********************************************************************************************
00159 
00160 >   PixelGreyscale
00161 
00162     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00163     Created:    3/7/96
00164     Purpose:    This value (a BYTE) represents an 8bpp greyscale pixel value
00165 
00166     SeeAlso:    OILBtmap::PlotPixel; OILBtmap::ReadPixel
00167 
00168 **********************************************************************************************/ 
00169 
00170 typedef BYTE PixelGreyscale;
00171 
00172 
00173 
00174 /*********************************************************************************************
00175 
00176 >   class OriginalBitmapRef : public CCObject
00177 
00178     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00179     Created:    8/8/96
00180     Purpose:    A reference to the original bitmap, before it was decompressed.
00181 
00182 **********************************************************************************************/ 
00183 
00184 class OriginalBitmapRef : public CCObject
00185 {
00186     CC_DECLARE_DYNAMIC( OriginalBitmapRef )
00187 
00188 public:
00189     OriginalBitmapRef(BitmapSource* pSource = NULL, BaseBitmapFilter* pImportFilter = NULL);
00190     ~OriginalBitmapRef();
00191 
00192     void SetOriginalSource(BitmapSource* pSource = NULL, BaseBitmapFilter* pImportFilter = NULL);
00193     BOOL GetOriginalSource(BitmapSource** ppSource = NULL, BaseBitmapFilter** ppImportFilter = NULL);
00194 
00195 protected:
00196     BitmapSource*       m_pBitmapSource;
00197     BaseBitmapFilter*   m_pBitmapFilter;
00198 };
00199 
00200 
00201 /*********************************************************************************************
00202 
00203 >   class OILBitmap : public ListItem
00204 
00205     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00206     Created:    11/8/94
00207     Purpose:    To encapsulate the OILy end of bitmaps. Each OIL layer inherits from this
00208                 and puts real functionality into the class. Things defined in this class
00209                 must remain kernel-ly.
00210 
00211 **********************************************************************************************/ 
00212 
00213 class OILBitmap : public ListItem
00214 {
00215     CC_DECLARE_DYNAMIC( OILBitmap )
00216 
00217     // These are the only classes allowed to create and delete bitmaps
00218     friend class KernelBitmap;
00219     friend class GlobalBitmapList;
00220 //  friend class GreyscaleBitmapList;
00221     friend class OpDeleteBitmap;
00222     friend class CachedFractal;
00223     friend class NodeCacheCompound;
00224     friend class FeatherAttrValue;
00225     friend class MaskedFilter;
00226     friend class FlashRenderRegion;
00227     friend class CBitmapCache;
00228 
00229 protected:
00230     // these are protected because hardly anyone is allowed to create these directly
00231     OILBitmap();
00232     virtual ~OILBitmap();
00233 
00234     // makes a bitmap of the correct type for the platform
00235     static OILBitmap* Create(UINT32 Width, UINT32 Height, UINT32 Depth, UINT32 dpi);
00236 
00237     // Remove the bitmap from the global list
00238     BOOL RemoveFromGlobalList();
00239 
00240 public:
00241     // static member variables
00242     static OILBitmap* Default;
00243     static INT32 s_lMaxGreyscaleSize;
00244 
00245     // public static fns
00246     static OILBitmap* Create();
00247     static OILBitmap* Attach( OILBitmap* = Default ,BOOL Temp = FALSE );
00248     static BOOL Init();
00249     static void Deinit();
00250 
00251     // public member variables
00252     virtual INT32 operator==(const OILBitmap&) = 0;
00253     virtual BOOL GetInfo(BitmapInfo* Info, RenderRegion* pRegion = NULL) = 0;
00254 
00255     virtual UINT32 GetWidth() = 0;
00256     virtual UINT32 GetHeight() = 0;
00257     virtual UINT32 GetBPP(RenderRegion* pRegion = NULL) = 0;
00258     virtual UINT32 GetNumPaletteEntries() = 0;
00259     virtual ADDR GetBitmapBits() = 0;
00260 
00261     virtual UINT32 GetScanlineSize() = 0;
00262     UINT32 GetBitmapSize();
00263 
00264     void SetName(String_256& NewName)       { m_BitmapName = NewName; }
00265     String_256& GetName()                   { return m_BitmapName; }
00266 
00267     void SetBitmapAnimDelay (UINT32 Delay)  { m_BitmapAnimDelay = Delay; }
00268     UINT32 GetBitmapAnimDelay ()                { return m_BitmapAnimDelay; }
00269 
00270     void SetInterpolation(BOOL Value)       { m_bInterpolation = Value; }
00271     BOOL GetInterpolation()                 { return m_bInterpolation ; }
00272 
00273     void SetHidden(BOOL Value)              { m_bHidden = Value; }
00274     BOOL IsHidden() const                   { return m_bHidden ; }
00275     BOOL IsHiddenInGallery();
00276 
00277     void SetAnimationRestoreType(GIFDisposalMethod Type)    { m_AnimationRestoreType = Type; }
00278     GIFDisposalMethod GetAnimationRestoreType ()            { return m_AnimationRestoreType; }  
00279     void SetLeftOffset(UINT32 LeftOffset)   { m_LeftOffset = LeftOffset; }
00280     UINT32 GetLeftOffset()              { return m_LeftOffset; }
00281     void SetTopOffset(UINT32 TopOffset) { m_TopOffset = TopOffset; }
00282     UINT32 GetTopOffset()                   { return m_TopOffset; }
00283 
00284     BOOL InvalidateAllReferences(Document*);
00285     BOOL IsUsedInDocument(Document* pDoc, BOOL bIncludeHidden = FALSE);
00286     BOOL IsUsedByChildren(Node* pNode, BOOL bIncludeHidden = FALSE);
00287     BOOL IsUsedByNode(Node* pNode);
00288 
00289     // for loading/saving bitmaps to EPS RenderRegions
00290     virtual BOOL ExportBitmap(RenderRegion *pRegion) = 0;
00291     virtual BOOL ExportBitmapPalette(RenderRegion *pRegion) = 0;
00292     virtual BOOL ExportBitmapData(RenderRegion *pRegion) = 0;
00293 
00294     virtual INT32 GetRecommendedWidth() = 0;
00295     virtual INT32 GetRecommendedHeight() = 0;
00296     virtual void SetRecommendedWidth(INT32) = 0;
00297     virtual void SetRecommendedHeight(INT32) = 0;
00298 
00299     virtual BOOL SetTransparencyIndex(INT32) = 0;
00300     virtual BOOL GetTransparencyIndex(INT32*) = 0;
00301     virtual BOOL IsTransparent() = 0;
00302 
00303     // For exporting bitmaps to postscript with colour-separation
00304     virtual BOOL ExportSeparatedData(RenderRegion *pRegion, BYTE *SepTables) = 0;
00305     virtual BOOL ExportSeparatedPalette(RenderRegion *pRegion) = 0;
00306 
00307     // Helper function used by ExportSeparatedData - this retrieves one scanline of the
00308     // bitmap as generic 32bpp RGB data.
00309     virtual BOOL GetScanline32bpp(UINT32 YPos, BOOL UsePalette, Pixel32bpp *Scanline) = 0;
00310 
00311     // Function used when exporting an 8bpp JPEG into the web file
00312     virtual BOOL WritePalette(BaseCamelotFilter *pFilter) = 0;
00313     // Function used when importing that 24bpp JPEG back in and wanting it in 8bpp format
00314     virtual BOOL Convert24To8(RGBTRIPLE *pPalette, UINT32 NumberOfPaletteEntries) = 0;
00315 
00316     // Function used by the native/web filters to pull a bitmap from inside a bitmap
00317     // definition record
00318     virtual BOOL ImportBitmap(CCLexFile* pFile, BaseBitmapFilter* pBitmapFilter,
00319                               BaseCamelotFilter* pFilter, BOOL IsCompressed) = 0;
00320 
00321     // Function used by the EPS filters to import bitmaps and by the bitmap filter
00322     // to import a bitmap directly from a bitmap file
00323     virtual BOOL ImportBitmap(Filter*, const BitmapInfo*, INT32) = 0;
00324 
00325     virtual BOOL LoadBitmap(UINT32 BitmapResourceID) = 0;
00326 
00327     virtual BOOL GetPaletteUsage(INT32 *) = 0;
00328     virtual BOOL PrepareMask(INT32 PaletteEntry) = 0;
00329     virtual BOOL GetScanlineMaskBits(INT32 ScanlineY, LPBYTE ScanlineBuf) = 0;
00330     virtual BOOL DestroyMask() = 0;
00331 
00332     virtual BOOL BuildContonePalette(DocColour &Start, DocColour &End, EFFECTTYPE Effect, View *ScopeView);
00333     virtual BOOL ExportContonePalette(RenderRegion *) = 0;
00334     virtual DocColour GetContonePaletteEntry(UINT32 PaletteIndex);
00335     virtual BOOL DestroyContonePalette();
00336 
00337     virtual void PlotPixel(INT32 x, INT32 y, Pixel32bpp NewValue) = 0;
00338     virtual void PlotPixel(INT32 x, INT32 y, PixelGreyscale NewValue) = 0;
00339     virtual Pixel32bpp ReadPixel32bpp (INT32 x, INT32 y, BOOL UsePalette = TRUE) = 0;
00340     virtual INT32 ReturnPaletteIndexUsed( INT32 x, INT32 y ) = 0;
00341     virtual PixelGreyscale ReadPixelGreyscale (INT32 x, INT32 y) = 0;
00342 
00343     // New function to free the actual bitmap memory
00344     virtual void DeleteData(BOOL bResetToDefault = TRUE) = 0;
00345     virtual BOOL HasBeenDeleted() = 0;
00346 
00347     // Functions to access the orginal bitmap file
00348     virtual void SetOriginalSource(BitmapSource* pSource = NULL, BaseBitmapFilter* pImportFilter = NULL);
00349     virtual BOOL GetOriginalSource(BitmapSource** ppSource = NULL, BaseBitmapFilter** ppImportFilter = NULL);
00350 
00351     // Functions for contoning
00352     virtual BOOL SetGreyscaleVersion(OILBitmap*);
00353     virtual BOOL DestroyGreyscaleVersion();
00354     virtual OILBitmap* GetGreyscaleVersion() { return m_pGreyscaleVersion; }
00355 
00356     virtual void GenerateGreyscaleTable() = 0;
00357     BYTE* GetGreyscaleTable() { return m_pGreyscaleTable; }
00358 
00359     BOOL IsGreyscale() { return m_bIsGreyscale; }
00360     BOOL IsDefaultBitmap() { return this == OILBitmap::Default || HasBeenDeleted(); }
00361     BOOL IsTemp() { return m_bTemp; }       
00362     BOOL IsInGlobalList() { return !m_bTemp; }
00363     BOOL IsLossy() { return m_bIsLossy; }
00364 
00365     void SetAsFractal() { m_bIsAFractal = TRUE;
00366                           m_bIsGreyscale = TRUE; }
00367 
00368     void SetAsGreyscale() { m_bIsGreyscale = TRUE; };
00369         // Informs this object that the bitmap it contains *is* a greyscale 8bpp bitmap, and that
00370         // it therefore doesn't need to make a copy in GetGreyscaleVersion()
00371 
00372     void SetAsLossy(BOOL bLossy = TRUE) { m_bIsLossy = bLossy; };
00373     BOOL IsAFractal() { return m_bIsAFractal; }
00374 
00375     virtual BOOL IsBrowserPalette() = 0;
00376     virtual BOOL ArePalettesTheSame(const LPLOGPALETTE pLogPalette, const INT32 TransColour = -1) = 0;
00377 
00378     virtual UINT32 GetHorizontalDPI() = 0;
00379     virtual UINT32 GetVerticalDPI() = 0;
00380 
00381     virtual LPBITMAPINFO        GetBitmapInfo()         = 0;
00382     virtual LPRGBQUAD           GetPaletteForBitmap()   = 0;
00383     virtual LPBITMAPINFOHEADER  GetBitmapInfoHeader()   = 0;
00384     virtual void                ReplaceBitmap(LPBYTE pBytes, LPBITMAPINFO pInfo) = 0;
00385 
00386     virtual OILBitmap* MakeCopy() = 0;
00387 
00388     void SetUsedByBrush(BOOL Used) { m_bUsedByBrush = Used;}
00389     BOOL IsUsedByBrush() { return m_bUsedByBrush; }
00390 
00391 PORTNOTE("other","Removed XML stuff")
00392 #ifndef EXCLUDE_FROM_XARALX
00393     virtual void        SetXPEInfo(OILBitmap* pMasterBitmap, IXMLDOMDocumentPtr pNewEditList);
00394     virtual void        GetXPEInfo(OILBitmap*& refMasterBitmap,
00395                                    IXMLDOMDocumentPtr& refEditList,
00396                                    BOOL bEnsureList = FALSE);
00397 #endif
00398     virtual BOOL        IsXPEMaster();
00399     virtual BOOL        DestroyXPEInfo();
00400     virtual BOOL        RemoveXPEBitmap();
00401     virtual BOOL        RebuildXPEBitmap();
00402     virtual BOOL        NeedsXPERebuild();
00403 
00404     virtual void CopyFullyTransparentFrom(OILBitmap* pBitmap) = 0;
00405 
00406 protected:
00407     String_256 m_BitmapName;
00408     UINT32 m_BitmapAnimDelay;
00409     BOOL m_bInterpolation;          // 'smooth when scaled up' property
00410     GIFDisposalMethod   m_AnimationRestoreType;
00411     UINT32 m_LeftOffset;
00412     UINT32 m_TopOffset;
00413 
00414     // Link to the original version of the bitmap
00415     OriginalBitmapRef m_OriginalBitmap;
00416 
00417     // Contoning stuff
00418     OILBitmap*  m_pColourVersion;
00419     OILBitmap*  m_pGreyscaleVersion;
00420     RGBQUAD*    m_pContonePalette;
00421     BYTE*       m_pGreyscaleTable;
00422 
00423     // XPE stuff
00424     OILBitmap* m_pMasterBitmap;
00425 PORTNOTE("other","Removed XML stuff")
00426 #ifndef EXCLUDE_FROM_XARALX
00427     IXMLDOMDocumentPtr m_pEditList;
00428 #endif
00429     // Flags
00430     BOOL m_bTemp : 1;               // This is a temp bitmap (ie. It's not in the global bitmap list)
00431     BOOL m_bIsAFractal : 1;
00432     BOOL m_bIsGreyscale : 1;
00433     BOOL m_bUsedByBrush : 1;
00434     BOOL m_bNeedsXPERebuild : 1;    // Bitmap data has been removed from memory, can be rebuilt from m_pMasterBitmap and m_pEditList
00435     BOOL m_bHidden : 1;             // Should not show up in bitmap gallery
00436     BOOL m_bIsLossy : 1;
00437 
00438 #ifdef _DEBUG
00439     // Debug flag, so we can detect multiple references to temp bitmaps
00440     BOOL m_bIsAttached : 1;
00441 #endif
00442 };
00443 
00444 
00445 /*********************************************************************************************
00446 
00447 >   class KernelBmpListItem : public ListItem
00448 
00449     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00450     Created:    19/09/05
00451     Purpose:    Holds a pointer to a KernelBitmap for tracking the creation of
00452                 bitmaps for cleanup purposes.  This class should be eliminated 
00453                 by modifying the bitmap classes to correctly reference count and 
00454                 handle the concept of temporary bitmaps.
00455 
00456 **********************************************************************************************/ 
00457 
00458 class KernelBmpListItem : public ListItem
00459 {
00460 public:
00461     CC_DECLARE_DYNAMIC( KernelBmpListItem )
00462     KernelBmpListItem(KernelBitmap* pBmp = NULL)
00463     {
00464         m_pBmp = pBmp;
00465     }
00466     
00467     KernelBitmap* m_pBmp;           // pointer to bitmap
00468 };
00469 
00470 /*********************************************************************************************
00471 
00472 >   class KernelBitmap : public ListItem
00473 
00474     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00475     Created:    11/8/94
00476     Purpose:    To encapsulate bitmaps, which are implemented in the OIL layer. Kernel code
00477                 is only allowed to use this interface. OIL code is allowed to use the
00478                 specific OILy functions that can be done via the OILBitmap pointer.
00479 
00480 **********************************************************************************************/ 
00481 
00482 
00483 class KernelBitmap : public ListItem
00484 {
00485     friend class BitmapList;
00486 
00487     CC_DECLARE_DYNAMIC( KernelBitmap )
00488 
00489 public:
00490     KernelBitmap( OILBitmap *pBitmap = NULL, BOOL Temp = FALSE );
00491     KernelBitmap( const KernelBitmap& );
00492     KernelBitmap( UINT32, UINT32, UINT32, UINT32, BOOL Temp = FALSE );
00493     ~KernelBitmap();
00494 
00495     static KernelBitmap* MakeKernelBitmap(OILBitmap *pBitmap = NULL,
00496                                           Document *pDoc = NULL,
00497                                           BOOL bAlwaysNew = FALSE);
00498 
00499     static void SetCreateTracker(List* pList)
00500     {
00501         s_pTrackerList = pList;
00502     }
00503     static List* s_pTrackerList;
00504 
00505     INT32 operator==(const KernelBitmap&);
00506     KernelBitmap& operator=(const KernelBitmap&);
00507 
00508     inline OILBitmap* GetActualBitmap() const { return ActualBitmap; }
00509 
00510     BOOL IsOK() const;
00511 
00512     // Function used when exporting an 8bpp JPEG into the web file
00513     virtual BOOL WritePalette(BaseCamelotFilter *pFilter);
00514     // Function used when importing that 24bpp JPEG back in and wanting it in 8bpp format
00515     virtual BOOL Convert24To8(RGBTRIPLE *pPalette, UINT32 NumberOfPaletteEntries);
00516 
00517     // Function used by the native/web filters to pull a bitmap from inside a bitmap
00518     // definition record
00519     static BOOL ImportBitmap(CCLexFile* pFile, BaseBitmapFilter *pBitmapFilter, BaseCamelotFilter *pFilter,
00520                              BOOL IsCompressed,
00521                              RGBTRIPLE *pPalette, UINT32 NumberOfPaletteEntries,
00522                              KernelBitmap** ppImportedBitmap, BOOL* IsNew);
00523     // Function used by the EPS filters to import bitmaps and by the bitmap filter
00524     // to import a bitmap directly from a bitmap file
00525     static BOOL ImportBitmap(Filter *pFilter, const BitmapInfo *pInfo, INT32 BitmapType,
00526                              KernelBitmap**, BOOL*);
00527 
00528     static KernelBitmap* TryAndUseExistingBitmap(OILBitmap* pOILBitmap, Document* pDoc, 
00529                                                  BOOL* IsNew);
00530 
00531     inline void PlotPixel(INT32 x, INT32 y, Pixel32bpp NewValue);
00532     inline void PlotPixel(INT32 x, INT32 y, PixelGreyscale NewValue);
00533     inline Pixel32bpp ReadPixel32bpp(INT32 x, INT32 y, BOOL UsePalette = TRUE) const;
00534     inline INT32 ReturnPaletteIndexUsed( INT32 x, INT32 y ) const;
00535     inline PixelGreyscale ReadPixelGreyscale(INT32 x, INT32 y) const;
00536     ADDR GetBitmapBits() const;
00537 
00538     BitmapList* GetParentBitmapList() { return m_pParentList; }
00539     BOOL IsUsedInDocument(Document* pDoc, BOOL bIncludeHidden = FALSE);
00540 
00541     void Attach(BitmapList* = NULL);
00542     void Detach();
00543 
00544     UINT32 GetWidth() const;
00545     UINT32 GetHeight() const;
00546     UINT32 GetBPP();
00547     UINT32 GetNumPaletteEntries() const;
00548 
00549     INT32 GetRecommendedWidth();
00550     INT32 GetRecommendedHeight();
00551     void SetRecommendedWidth(INT32);
00552     void SetRecommendedHeight(INT32);
00553 
00554     BOOL SetTransparencyIndex(INT32);
00555     BOOL GetTransparencyIndex(INT32* pIndex);
00556     BOOL IsTransparent();
00557 
00558     BOOL IsDefaultBitmap();
00559     BOOL HasBeenDeleted();
00560     BOOL IsGreyscale();
00561     BOOL IsLossy();
00562 
00563     // Functions to access the orginal bitmap file
00564     void SetOriginalSource(BitmapSource* pFileBuffer = NULL, BaseBitmapFilter* pImportFilter = NULL);
00565     BOOL GetOriginalSource(BitmapSource** ppFileBuffer = NULL, BaseBitmapFilter** ppImportFilter = NULL);
00566 
00567     // Functions for contoning
00568     BOOL CreateGreyscaleVersion(BOOL ForceGreyBmp = FALSE);
00569     BOOL DestroyGreyscaleVersion();
00570     OILBitmap* GetGreyscaleVersion(BOOL ForceGreyBmp = FALSE);
00571 
00572     OILBitmap* ExtractOILBitmap();
00573     void GenerateGreyscaleTable();
00574 
00575     BOOL SetAsFractal();
00576     BOOL SetAsGreyscale();
00577     BOOL SetAsLossy(BOOL bLossy = TRUE);
00578 
00579     UINT32 GetDelay();
00580     void SetDelay(UINT32 Delay);
00581 
00582     BOOL GetInterpolation();
00583     void SetInterpolation(BOOL bInterpolation);
00584 
00585     void SetAnimationRestoreType(GIFDisposalMethod Type);
00586     GIFDisposalMethod GetAnimationRestoreType() const;
00587 
00588     void SetLeftOffset(UINT32 LeftOffset);
00589     UINT32 GetLeftOffset() const;
00590     void SetTopOffset(UINT32 TopOffset);
00591     UINT32 GetTopOffset() const;
00592 
00593     BOOL IsBrowserPalette() const;
00594     BOOL ArePalettesTheSame(const LPLOGPALETTE pLogPalette, const INT32 TransColour = -1);
00595 
00596     UINT32 GetHorizontalDPI() const;
00597     UINT32 GetVerticalDPI() const;
00598 
00599     void SetName(String_256& NewName);
00600     String_256& GetName();
00601 
00602     // These should only really be used by Winoil code
00603     LPBITMAPINFO        GetBitmapInfo();
00604     LPRGBQUAD           GetPaletteForBitmap();
00605     LPBITMAPINFOHEADER  GetBitmapInfoHeader();
00606 
00607     void SetUsedByBrush(BOOL Used) { m_bUsedByBrush = Used;}
00608     BOOL IsUsedByBrush() { return m_bUsedByBrush;}
00609 
00610 PORTNOTE("other","Removed XML stuff")
00611 #ifndef EXCLUDE_FROM_XARALX
00612     virtual void        SetXPEInfo(KernelBitmap* pMasterBitmap, IXMLDOMDocumentPtr pNewEditList);
00613     virtual void        GetXPEInfo(KernelBitmap*& refMasterBitmap,
00614                                    IXMLDOMDocumentPtr& refEditList,
00615                                    BOOL bEnsureList = FALSE);
00616 #endif
00617     virtual BOOL        IsXPEMaster();
00618     virtual BOOL        DestroyXPEInfo();
00619     virtual void        ReplaceOILBitmap(LPBYTE pBits, LPBITMAPINFO pInfo);
00620 
00621     // attach a copy of this bitmap to the current doc's bitmap gallery.
00622     // see method definition for more info.
00623 #ifdef _DEBUG
00624 public:
00625     BOOL AttachDebugCopyToCurrentDocument(String_256 strName);
00626 #endif
00627 
00628 public:
00629     OILBitmap *ActualBitmap;
00630 
00631 protected:
00632     BitmapList* m_pParentList;
00633 
00634     BOOL m_bDontDeleteActualBitmap : 1;
00635     BOOL m_bFractalAttached : 1;
00636     BOOL m_bUsedByBrush : 1;
00637 
00638 };
00639 
00640 /*********************************************************************************************
00641 
00642 >   class KernelBitmapRef : public CCObject
00643 
00644     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00645     Created:    12/12/94
00646     Purpose:    A reference to a KernelBitmap object.
00647 
00648 **********************************************************************************************/ 
00649 
00650 class KernelBitmapRef : public CCObject
00651 {
00652     CC_DECLARE_DYNAMIC( KernelBitmapRef )
00653 
00654 public:
00655     KernelBitmapRef();
00656     ~KernelBitmapRef();
00657 
00658     INT32 operator==(const KernelBitmapRef&);
00659     KernelBitmapRef& operator=(KernelBitmapRef&);
00660 
00661     void Attach(KernelBitmap*, Document* Doc = NULL);
00662     void Detach(BOOL bTryRemoveFromDoc = FALSE);
00663     void DeleteBmp();
00664 
00665     void RemoveFromTree();
00666     void AddtoTree();
00667     BOOL IsHidden() { return m_bHidden; }
00668 
00669     KernelBitmap* GetBitmap() { return m_pTheBitmap; }
00670     void SetBitmap(KernelBitmap*);
00671 
00672 protected:
00673     KernelBitmap* m_pTheBitmap;
00674 
00675     BOOL m_bHidden;     // Is this ref in a hidden sub-tree
00676 };
00677 
00678 
00679 /*********************************************************************************************
00680 
00681 >   class BitmapPtr : public ListItem
00682 
00683     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00684     Created:    12/12/94
00685     Purpose:    A simple class containing a pointer to a kernel bitmap, so we can build
00686                 lists with them.
00687 
00688 **********************************************************************************************/ 
00689 
00690 class BitmapPtr : public ListItem
00691 {
00692     CC_DECLARE_DYNAMIC( BitmapPtr )
00693 
00694 public:
00695     KernelBitmap* m_TheBitmap;
00696 };
00697 
00698 /********************************************************************************************
00699 
00700 >   inline void KernelBitmap::PlotPixel(INT32 x, INT32 y, Pixel32bpp NewValue)
00701                     
00702     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> (Jason)
00703     Created:    13/9/94 (3/7/96)
00704     Inputs:     x, y - coordinates within the bitmap of the pixel to plot
00705                 NewValue - a 32bpp pixel value.
00706 
00707     Outputs:    (changes attached oil bitmap)
00708     Returns:    Nothing
00709     Purpose:    Plots a 32bpp pixel to a deep bitmap (16, 24, or 32bpp)
00710 
00711     Notes:      In debug builds, will check all kinds of stuff, but in release
00712                 builds, it assumes that you are providing legal offsets in the bitmap,
00713                 and are only using this call where it will work - this is to reduce
00714                 retail overhead on each pixel operation.
00715         
00716     Errors:     ERROR3 if the bitmap is not 16, 24, or 32bpp
00717 
00718     SeeAlso:    OILBitmap::PlotPixel
00719 
00720 ********************************************************************************************/
00721 
00722 inline void KernelBitmap::PlotPixel(INT32 x, INT32 y, Pixel32bpp NewValue)
00723 {
00724     ERROR3IF(ActualBitmap == NULL, "PlotPixel with no bitmap!");
00725     ActualBitmap->PlotPixel(x, y, NewValue);
00726 }
00727 
00728 
00729 
00730 /********************************************************************************************
00731 
00732 >   inline void KernelBitmap::PlotPixel(INT32 x, INT32 y, PixelGreyscale NewValue)
00733                     
00734     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00735     Created:    3/7/96
00736     Inputs:     x, y - coordinates within the bitmap of the pixel to plot
00737                 NewValue - an 8bpp pixel value, presumed to be a greyscale.
00738 
00739     Outputs:    (changes attached oil bitmap)
00740     Returns:    Nothing
00741 
00742     Purpose:    Plots an 8bpp (0..255) pixel to any type of bitmap
00743                 The pixel is taken to be a greyscale, and is truncated or expanded
00744                 as appropriate to fit the greyscale value into the destination bitmap
00745                 pixel format.
00746 
00747     Notes:      In debug builds, will check all kinds of stuff, but in release
00748                 builds, it assumes that you are providing legal offsets in the bitmap,
00749                 and are only using this call where it will work - this is to reduce
00750                 retail overhead on each pixel operation.
00751 
00752     SeeAlso:    OILBitmap::PlotPixel
00753 
00754 ********************************************************************************************/
00755 
00756 inline void KernelBitmap::PlotPixel(INT32 x, INT32 y, PixelGreyscale NewValue)
00757 {
00758     ERROR3IF(ActualBitmap == NULL, "PlotPixel with no bitmap!");
00759     ActualBitmap->PlotPixel(x, y, NewValue);
00760 }
00761 
00762 
00763 
00764 /********************************************************************************************
00765 
00766 >   inline Pixel32bpp KernelBitmap::ReadPixel32bpp(INT32 x, INT32 y, BOOL UsePalette = TRUE) const
00767                     
00768     Author:     Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com> (Jason)
00769     Created:    13/9/94 (3/7/96)
00770     Inputs:     x, y - coordinates of the pixel to read
00771                 UsePalette -Ignored for deep bitmaps
00772                             For <=8bpp bitmaps, if this value is:
00773                                 FALSE, the bitmap's palette will be ignored, and the actual pixel
00774                                 (palette index) value will be returned as a greyscale RGB value
00775                                 TRUE, the pixel index value will be used to retrieve the 24bpp
00776                                 palette entry for the pixel, if a palette is available.
00777 
00778     Outputs:    (changes attached oil bitmap)
00779     Returns:    The pixel value of the given pixel
00780 
00781     Purpose:    reads a pixel
00782 
00783     Notes:      In debug builds, will check all kinds of stuff, but in release
00784                 builds, it assumes that you are providing legal offsets in the bitmap,
00785                 and are only using this call where it will work - this is to reduce
00786                 retail overhead on each pixel operation.
00787 
00788     Errors:     -
00789     SeeAlso:    OILBitmap::ReadPixel32bpp
00790 
00791 ********************************************************************************************/
00792 
00793 inline Pixel32bpp KernelBitmap::ReadPixel32bpp(INT32 x, INT32 y, BOOL UsePalette) const
00794 {
00795     ERROR3IF(ActualBitmap == NULL, "PlotPixel with no bitmap!");
00796     return(ActualBitmap->ReadPixel32bpp(x, y));
00797 }
00798 
00799 
00800 // ap 29/9/99
00801 inline INT32 KernelBitmap::ReturnPaletteIndexUsed( INT32 x, INT32 y ) const
00802 {
00803     ERROR3IF(ActualBitmap == NULL, "Can't do anything without a bitmap");
00804     return(ActualBitmap->ReturnPaletteIndexUsed(x, y));
00805 }
00806 
00807 
00808 
00809 /********************************************************************************************
00810 
00811 >   inline PixelGreyscale KernelBitmap::ReadPixelGreyscale(INT32 x, INT32 y) const
00812                     
00813     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00814     Created:    3/7/96
00815     Inputs:     x, y - coordinates of the pixel to read
00816     Outputs:    (changes attached oil bitmap)
00817     Returns:    The pixel value of the given pixel
00818 
00819     Purpose:    Reads a pixel as a greyscale intensity value (0..255)
00820 
00821     Notes:      When reading a pixel from <8bpp bitmaps, the pixel value will be assumed
00822                 to be a greyscale, and will be expanded up to 8bpp.
00823                 When reading a pixel from a deep bitmap, the RGB value will be converted
00824                 into a greyscale intensity value.
00825 
00826                 In debug builds, will check all kinds of stuff, but in release
00827                 builds, it assumes that you are providing legal offsets in the bitmap,
00828                 and are only using this call where it will work - this is to reduce
00829                 retail overhead on each pixel operation.
00830 
00831     Errors:     -
00832     SeeAlso:    OILBitmap::ReadPixelGreyscale
00833 
00834 ********************************************************************************************/
00835 
00836 inline PixelGreyscale KernelBitmap::ReadPixelGreyscale(INT32 x, INT32 y) const
00837 {
00838     ERROR3IF(ActualBitmap == NULL, "PlotPixel with no bitmap!");
00839     return(ActualBitmap->ReadPixelGreyscale(x, y));
00840 }
00841 
00842 
00843 #endif

Generated on Sat Nov 10 03:44:23 2007 for Camelot by  doxygen 1.4.4