1 // $Id: pngfiltr.h 809 2006-04-13 11:28:42Z phil $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
96 =================================XARAHEADEREND============================
103 #include "maskfilt.h"
104 #include "outptpng.h"
105 #include "bmpprefs.h" // SelectionType
106 //#include "filtrres.h"
110 /********************************************************************************************
112 > class PNGExportOptions : public MaskedFilterExportOptions
114 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
116 Purpose: Base class for storing information about the bitmap we're exporting.
118 ********************************************************************************************/
120 class PNGExportOptions
: public MaskedFilterExportOptions
122 CC_DECLARE_DYNCREATE(PNGExportOptions
)
125 static BOOL
Declare();
127 PNGExportOptions(const FilterType FilterID
, const StringBase
* pFilterName
);
128 PNGExportOptions() {};
130 virtual BOOL
GetSupportsImageMap() { return TRUE
; }
132 virtual BOOL
RetrieveDefaults();
133 virtual BOOL
SetAsDefaults() const;
135 virtual UINT32
GetFilterNameStrID() { return _R(IDS_FILTERNAME_PNG
);}
140 static UINT32 g_CompactedFlagsForDefaults
;
143 /********************************************************************************************
145 > class PNGFilter : public MaskedFilter
147 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
149 Purpose: Encapsulates a PNG export filter.
150 Derives off the masked filter which provides funcitonality for doing masked
151 bitmap export and import.
153 ********************************************************************************************/
155 class PNGFilter
: public MaskedFilter
157 CC_DECLARE_DYNAMIC(PNGFilter
);
164 virtual INT32
HowCompatible( PathName
& Filename
, ADDR HeaderStart
, UINT32 HeaderSize
,
167 virtual FilterType
GetFilterType() const { return PNG
; }
169 // Import related functions
170 virtual BOOL
ReadFromFile(OILBitmap
* pOilBitmap
);
171 // This is the function for native/web files to use
172 virtual BOOL
ReadFromFile(OILBitmap
* pOilBitmap
, BaseCamelotFilter
* pFilter
,
173 CCLexFile
* pFile
, BOOL IsCompressed
);
175 // Function for web/native filters to use to write out the bitmap data to file
176 virtual BOOL
WriteBitmapToFile(KernelBitmap
* pKernelBitmap
, BaseCamelotFilter
* pFilter
,
177 CCLexFile
* pFile
, INT32 Compression
);
179 // Check if this Bitmap filter can cope with saving at this Bpp/Colour depth
180 virtual BOOL
IsThisBppOk(UINT32 Bpp
);
182 // Public way of finding out how compatable the PNG filter thought the file was
183 // We might want to bring in the Accusoft filter to help out.
184 virtual INT32
GetPNGCompatibility() { return PNGHowCompatible
; }
187 virtual UINT32
GetExportMsgID();
188 virtual void PostGetExportOptions(BitmapExportOptions
* pOptions
);
192 // Invert the alpha channel.
193 virtual void InvertAlpha ( LPBITMAPINFO lpBitmapInfo
,
196 // Get the correct output DIB.
197 virtual OutputDIB
* GetOutputDIB ( void );
199 virtual BitmapExportOptions
* CreateExportOptions() const;
201 virtual BOOL
GetExportOptions( BitmapExportOptions
* pOptions
);
202 virtual void CleanUpAfterExport();
203 virtual BOOL
EndWriteToFile();
205 virtual BOOL
WriteFileHeader(void) { return TRUE
; }
206 virtual BOOL
WritePreFrame(void);
207 virtual BOOL
WritePreSecondPass(void);
208 virtual BOOL
WritePostOptimisedPalette(void) { return TRUE
; }
209 virtual BOOL
WriteFrame(void);
210 virtual BOOL
WritePostFrame(void);
211 virtual BOOL
WriteFileEnd(void);
213 virtual BOOL
WriteBitmapToFile(KernelBitmap
* pKernelBitmap
, double Dpi
);
215 // this is used for the actual writing of the file
216 static BOOL
WriteDataToFile( BOOL End
, UINT32 Bpp
, UINT32 Compression
);
217 static BOOL
WriteToFile ( CCLexFile
*, LPBITMAPINFO Info
, LPBYTE Bits
,
218 String_64
* ProgressString
= NULL
);
220 // This is the form used for direct saving bitmaps into the native/web file format
221 static BOOL
WriteToFile ( CCLexFile
*, LPBITMAPINFO Info
, LPBYTE Bits
,
222 BOOL Interlace
, INT32 TransparentColour
,
223 BaseCamelotFilter
* pFilter
= NULL
);
225 void AlterPaletteContents( LPLOGPALETTE pPalette
);//ap
228 // The class we use for actually outputting the PNG data and converting from 32 to n bpps
229 static OutputPNG DestPNG
;
232 // This is so we can remember what we thought of the GIF file.
233 INT32 PNGHowCompatible
;
235 static FilterType s_FilterType
; // Type of filter in use i.e. PNG
237 // The string to display when exporting the second stage.
238 UINT32 Export2ndStageMsgID
;
241 #endif // INC_PNGFILTR