oilbitmap.h

Go to the documentation of this file.
00001 // $Id: oilbitmap.h 1366 2006-06-26 11:18:18Z 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 // Windows Bitmap object
00100 
00101 #ifndef INC_WBITMAP
00102 #define INC_WBITMAP
00103 
00104 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 
00106 class Filter;
00107 class BitmapInfo;
00108 class BaseBitmapFilter;
00109 class BaseCamelotFilter;
00110 class CCLexFile;
00111 class ColourPlate;
00112 
00113 /*********************************************************************************************
00114 
00115 >   class CWxBitmap : public OILBitmap
00116 
00117     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00118     Created:    11/8/94
00119     Purpose:    The Windows implementation of the OILBitmap class. Based on a non-compressed
00120                 DIB. Kernel code should not call on functions in this class except via
00121                 the OILBitmap interface.
00122 
00123 **********************************************************************************************/ 
00124 
00125 class CWxBitmap : public OILBitmap
00126 {
00127     CC_DECLARE_DYNAMIC( CWxBitmap )
00128 
00129     friend BOOL OILBitmap::Init();
00130     friend void OILBitmap::Deinit();
00131     friend OILBitmap *OILBitmap::Create();
00132     friend OILBitmap *OILBitmap::Create(UINT32,UINT32,UINT32,UINT32);
00133 
00134 public:
00135     CWxBitmap();
00136     CWxBitmap(LPBITMAPINFO, LPBYTE);
00137     ~CWxBitmap();
00138 
00139     virtual INT32 operator==(const OILBitmap&);
00140 
00141     void CacheGeometry();
00142 
00143     virtual BOOL GetInfo(BitmapInfo *Info, RenderRegion *pRegion = NULL);
00144 
00145     virtual UINT32 GetWidth();
00146     virtual UINT32 GetHeight();
00147     virtual UINT32 GetBPP(RenderRegion *pRegion = NULL);
00148     virtual UINT32 GetNumPaletteEntries();
00149     virtual ADDR GetBitmapBits() {  return (ADDR)BMBytes;   }
00150 
00151     virtual UINT32 GetScanlineSize();
00152 
00153     virtual BOOL ExportBitmap(RenderRegion *pRegion);
00154     virtual BOOL ExportBitmapPalette(RenderRegion *pRegion);
00155     virtual BOOL ExportBitmapData(RenderRegion *pRegion);
00156 
00157     // For exporting bitmaps to postscript with colour-separation
00158     virtual BOOL ExportSeparatedData(RenderRegion *pRegion, BYTE *SepTables);
00159     virtual BOOL ExportSeparatedPalette(RenderRegion *pRegion);
00160 
00161     // Helper function used by ExportSeparatedData - this retrieves one scanline of the
00162     // bitmap as generic 24bpp RGB data.
00163     virtual BOOL GetScanline32bpp(UINT32 YPos, BOOL UsePalette, Pixel32bpp *Scanline);
00164     virtual wxImage * MakewxImage(UINT32 ImageWidth=0, UINT32 ImageHeight=0, BOOL UsePalette=TRUE);
00165 
00166     virtual OILBitmap* MakeCopy(); // returns a copy of this object
00167 protected:
00168     BOOL ExportBitmapPaletteInternal(RenderRegion *pRegion, INT32 NumColours, RGBQUAD *pSrcCLUT);
00169             // Shared code used by ExportBitmapPalette and ExportContonePalette
00170 
00171 
00172 public:     // Outputting bitmap scanlines in colour-separated form
00173     static void ColourSeparateScanline32to8(ColourContext *CurrentColContext, BYTE *SepTables,
00174                                                 BYTE *DestBuffer, Pixel32bpp *SrcBuffer,
00175                                                 INT32 PixelWidth);
00176 
00177     virtual void ColourSeparate32to32(ColourPlate* pPlate, BYTE *SepTables);
00178     virtual OILBitmap* MakeSeparatedCopy(ColourPlate* pPlate, BYTE *SepTables); // returns a copy of this object separated
00179 
00180     virtual INT32 GetRecommendedWidth();
00181     virtual INT32 GetRecommendedHeight();
00182     virtual void SetRecommendedWidth(INT32);
00183     virtual void SetRecommendedHeight(INT32);
00184 
00185     virtual BOOL SetTransparencyIndex(INT32);
00186     virtual BOOL GetTransparencyIndex(INT32*);
00187 
00188     virtual BOOL IsTransparent();
00189 
00190 public:
00191     // Function used when exporting an 8bpp JPEG into the web file
00192     virtual BOOL WritePalette(BaseCamelotFilter *pFilter);
00193     // Function used when importing that 24bpp JPEG back in and wanting it in 8bpp format
00194     virtual BOOL Convert24To8(RGBTRIPLE *pPalette, UINT32 NumberOfPaletteEntries);
00195 
00196     // Function used by the native/web filters to pull a bitmap from inside a bitmap
00197     // definition record
00198     virtual BOOL ImportBitmap(CCLexFile* pFile, BaseBitmapFilter* pBitmapFilter,
00199                               BaseCamelotFilter* pFilter, BOOL IsCompressed);
00200     
00201     // Function used by the EPS filters to import bitmaps and by the bitmap filter
00202     // to import a bitmap directly from a bitmap file
00203     virtual BOOL ImportBitmap(Filter*, const BitmapInfo*, INT32);
00204 
00205     virtual BOOL LoadBitmap(UINT32 BitmapResourceID);
00206     virtual BOOL CreateFromwxBitmap(wxBitmap * pBitmap);
00207     virtual BOOL CreateFromwxImage(wxImage * pImage);
00208 
00209     virtual BOOL GetPaletteUsage(INT32 *);
00210     virtual BOOL PrepareMask(INT32 PaletteEntry);
00211     virtual BOOL GetScanlineMaskBits(INT32 ScanlineY, LPBYTE ScanlineBuf);
00212     virtual BOOL DestroyMask();
00213     virtual BOOL ExportContonePalette(RenderRegion *);
00214 
00215     virtual void PlotPixel(INT32 x, INT32 y, Pixel32bpp NewValue);
00216     virtual void PlotPixel(INT32 x, INT32 y, PixelGreyscale NewValue);
00217     virtual Pixel32bpp ReadPixel32bpp (INT32 x, INT32 y, BOOL UsePalette = TRUE);
00218     virtual INT32 ReturnPaletteIndexUsed( INT32 x, INT32 y );
00219     virtual PixelGreyscale ReadPixelGreyscale (INT32 x, INT32 y);
00220 
00221     virtual void DeleteData(BOOL bResetToDefault = TRUE);
00222     virtual BOOL HasBeenDeleted();
00223 
00224     // retrieves the actual bitmap and sets members to NULL
00225     void ExtractBitsAndInfo(LPBYTE*, LPBITMAPINFO*);
00226 
00227     virtual void GenerateGreyscaleTable();
00228 
00229     INT32 ScanLineByteWidth;        // Bytes per scanline, including padding (i.e. offset from scanline to next)
00230     INT32 BitmapSize;           // Memory usage in bytes
00231 
00232     virtual BOOL IsBrowserPalette();
00233     virtual BOOL ArePalettesTheSame(const LPLOGPALETTE pLogPalette, const INT32 TransColour = -1);
00234 
00235     virtual UINT32 GetHorizontalDPI();
00236     virtual UINT32 GetVerticalDPI();
00237 
00238     virtual void CopyFullyTransparentFrom(OILBitmap* pBitmap);
00239 
00240     // these are public but MUST NOT be used from kernel code
00241 
00242     LPBITMAPINFO        BMInfo;     // The information on the bitmap
00243     LPBYTE              BMBytes;    // The actually pixels that make up the bitmap
00244 
00245     // BITMAPINFO  consists of:-
00246     //      BITMAPINFOHEADER    bmiHeader;
00247     //      RGBQUAD             bmiColors[1];
00248     // So allow access to them
00249     virtual LPBITMAPINFO        GetBitmapInfo();
00250     virtual LPRGBQUAD           GetPaletteForBitmap();
00251     virtual LPBITMAPINFOHEADER  GetBitmapInfoHeader();
00252     virtual void                ReplaceBitmap(LPBYTE pBytes, LPBITMAPINFO pInfo);
00253 };
00254 
00255 
00256 // These are some debug macros for detecting if a bitmap pointer is valid or not.
00257 
00258 // They work by looking for specific values that the memory gets set to when the object
00259 // gets deleted in a debug build. I'm not entirly sure why they get set to these particular
00260 // values ... but who cares.  It works, and that's all that's important.
00261 #define ERROR3IF_KBMP_PTR_INVALID(ptr, literal)\
00262         ERROR3IF( !IsValidAddress( ptr, 1 ), literal);
00263 #define ERROR2IF_KBMP_PTR_INVALID(ptr, retvalue, literal)\
00264         ERROR2IF( !IsValidAddress( ptr, 1 ), retvalue, literal);
00265 
00266 #define ERROR3IF_OILBMP_PTR_INVALID(ptr, literal)\
00267         ERROR3IF( !IsValidAddress( ptr, 1 ), literal );
00268 #define ERROR2IF_OILBMP_PTR_INVALID(ptr, retvalue, literal)\
00269         ERROR2IF( !IsValidAddress( ptr, 1 ), retvalue, literal);
00270 
00271 #endif

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