ppmfiltr.h

Go to the documentation of this file.
00001 // $Id: ppmfiltr.h 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 //
00099 
00100 #ifndef INC_PPMFILTR
00101 #define INC_PPMFILTR
00102 
00103 #include "bitfilt.h"
00104 //#include "outptdib.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "bmpprefs.h"   // SelectionType
00106 #include "maskedrr.h"   // MaskedRenderRegion derived off GRenderBitmap
00107 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 class KernelBitmap;
00110 //class OILFilter;
00111 
00112 enum PMFileType
00113 {
00114     PPM_BAD,
00115     PPM_BINARY,
00116     PPM_ASCII,  
00117     PGM_BINARY,
00118     PGM_ASCII,  
00119     PBM_BINARY,
00120     PBM_ASCII,  
00121 };  
00122 
00123 /********************************************************************************************
00124 
00125 >   class BasePMFilter : public BitmapFilter
00126 
00127     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00128     Created:    30/11/95
00129     Purpose:    Provides most of the the handling for the PPM, PGM and PBM filters.
00130 
00131 ********************************************************************************************/
00132 
00133 class BasePMFilter : public BaseBitmapFilter
00134 {
00135     CC_DECLARE_DYNAMIC(BasePMFilter);
00136     
00137 public:
00138     BasePMFilter();
00139 
00140     BOOL Init();
00141 
00142     virtual INT32 HowCompatible( PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize,
00143                                UINT32 FileSize );
00144     // Import related functions
00145     virtual BOOL ReadFromFile(OILBitmap* pOilBitmap);
00146 
00147 protected:
00148     //
00149     // Import related functions
00150     //
00151     //virtual BOOL PrepareToImport();
00152     //virtual void CleanUpAfterImport();
00153 
00154     BOOL ReadFromFile( CCLexFile *File, LPBITMAPINFO *Info, LPBYTE *Bits, String_64 *ProgressString = NULL);
00155 
00156     BOOL ReadASCIIFromFile( CCLexFile *pLexFile, LPBYTE pBits,
00157                             INT32   Width, INT32 Height, INT32 ColoursPerRGB, INT32 BitsPerRGB,
00158                             INT32 WidthOfLine,
00159                             String_64 *ProgressString = NULL, BOOL Forwards = TRUE);
00160     BOOL ReadBinaryFromFile( CCLexFile *pFile, LPBYTE pBits,
00161                              INT32 Width, INT32 Height, INT32 ColoursPerRGB, INT32 BitsPerRGB,
00162                              INT32 WidthOfLine,
00163                              String_64 *ProgressString = NULL, BOOL Forwards = TRUE);
00164 
00165     // Useful palette functions
00166     void PokePaletteEntry(LPRGBQUAD * Palette, BYTE red, BYTE green, BYTE blue);
00167     void MakeGreyScalePalette(LPRGBQUAD Palette);
00168     void Make16GreyScalePalette(LPRGBQUAD Palette);
00169     void MakeBlackAndWhitePalette(LPRGBQUAD Palette);
00170 
00171     // Functions that a filter derived off this must provide
00172     virtual BOOL CheckString(TCHAR * pHeader);
00173     virtual BOOL ReadDataIntoBitmap(INT32 Number, INT32 * Count, LPBYTE * pData, BOOL * NextPixel);
00174 
00175     // What the file type we are reading is
00176     PMFileType TypeOfPPM;
00177 
00178     // This is so we can remember what we thought of the GIF file.
00179     INT32 PPMHowCompatible; 
00180 
00181     INT32 x;                    // current x position across bitmap
00182     INT32 y;                    // current y position down bitmap
00183     INT32 TotalWidth;           // width in pixels of bitmap
00184     INT32 TotalHeight;      // height in pixels of bitmap
00185     INT32 TotalWidthOfLine; // width of lien rounded to required word boundaries
00186     INT32 RGBColours;           // number of colours per colour component
00187     INT32 RGBBits;          // bits per colour component e.g. R, G and B
00188     INT32 PixelCounter;     // how many pixels we get per read
00189 
00190     INT32 Red;              // red component for 24bit files
00191     INT32 Green;                // green component for 24bit files
00192     INT32 Blue;             // blue component for 24bit files
00193 
00194     BYTE Bits;              // accumulator for bits in 1bpp files
00195 
00196 public:
00197     // Check if this Bitmap filter can cope with saving at this Bpp/Colour depth
00198     virtual BOOL IsThisBppOk(UINT32 Bpp);
00199 };
00200 
00201 /********************************************************************************************
00202 
00203 >   class PPMFilter : public BitmapFilter
00204 
00205     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00206     Created:    30/11/95
00207     Purpose:    Encapsulates a Unix PPM import filter.
00208 
00209 ********************************************************************************************/
00210 
00211 class PPMFilter : public BasePMFilter
00212 {
00213     CC_DECLARE_DYNAMIC(PPMFilter);
00214     
00215 public:
00216     PPMFilter();
00217 
00218     BOOL Init();
00219 
00220 protected:
00221     virtual BOOL CheckString(TCHAR * pHeader);
00222     virtual BOOL ReadDataIntoBitmap(INT32 Number, INT32 * Count, LPBYTE * pData, BOOL * NextPixel);
00223 };
00224 
00225 /********************************************************************************************
00226 
00227 >   class PPMFilter : public BitmapFilter
00228 
00229     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00230     Created:    30/11/95
00231     Purpose:    Encapsulates a Unix PGM import filter.
00232 
00233 ********************************************************************************************/
00234 
00235 class PGMFilter : public BasePMFilter
00236 {
00237     CC_DECLARE_DYNAMIC(PGMFilter);
00238     
00239 public:
00240     PGMFilter();
00241 
00242     BOOL Init();
00243 
00244 protected:
00245     virtual BOOL CheckString(TCHAR * pHeader);
00246     virtual BOOL ReadDataIntoBitmap(INT32 Number, INT32 * Count, LPBYTE * pData, BOOL * NextPixel);
00247 };
00248 
00249 /********************************************************************************************
00250 
00251 >   class PBMFilter : public BitmapFilter
00252 
00253     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00254     Created:    30/11/95
00255     Purpose:    Encapsulates a Unix PBM import filter.
00256 
00257 ********************************************************************************************/
00258 
00259 class PBMFilter : public BasePMFilter
00260 {
00261     CC_DECLARE_DYNAMIC(PBMFilter);
00262     
00263 public:
00264     PBMFilter();
00265 
00266     BOOL Init();
00267 
00268 protected:
00269     virtual BOOL CheckString(TCHAR * pHeader);
00270     virtual BOOL ReadDataIntoBitmap(INT32 Number, INT32 * Count, LPBYTE * pData, BOOL * NextPixel);
00271 };
00272 
00273 
00274 /********************************************************************************************
00275 
00276 >   class PPMOILFilter : public OILFilter
00277 
00278     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00279     Created:    28/11/95
00280     Purpose:    Provide the OIL parts of the PPM filter which loads in the file as a BMP.
00281     SeeAlso:    PPMFilter
00282 
00283 ********************************************************************************************/
00284 
00285 class PPMOILFilter : public OILFilter
00286 {
00287 public:
00288     PPMOILFilter(Filter *pFilter);
00289 };
00290 
00291 /********************************************************************************************
00292 
00293 >   class PGMOILFilter : public OILFilter
00294 
00295     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00296     Created:    28/11/95
00297     Purpose:    Provide the OIL parts of the PGM filter which loads in the file as a BMP.
00298     SeeAlso:    PGMFilter
00299 
00300 ********************************************************************************************/
00301 
00302 class PGMOILFilter : public OILFilter
00303 {
00304 public:
00305     PGMOILFilter(Filter *pFilter);
00306 };
00307 
00308 /********************************************************************************************
00309 
00310 >   class PBMOILFilter : public OILFilter
00311 
00312     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00313     Created:    28/11/95
00314     Purpose:    Provide the OIL parts of the PBM filter which loads in the file as a BMP.
00315     SeeAlso:    PBMFilter
00316 
00317 ********************************************************************************************/
00318 
00319 class PBMOILFilter : public OILFilter
00320 {
00321 public:
00322     PBMOILFilter(Filter *pFilter);
00323 };
00324 
00325 
00326 
00327 #endif // INC_PPMFILTR
00328 
00329 

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