1 /********************************************************************************
2 *                                                                               *
3 *                            P P M   I m a g e   O b j e c t                    *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2003,2005 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXPPMImage.h,v 1.7 2005/01/16 16:06:06 fox Exp $                         *
23 ********************************************************************************/
24 #ifndef FXPPMIMAGE_H
25 #define FXPPMIMAGE_H
26 
27 #ifndef FXIMAGE_H
28 #include "FXImage.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Portable Pixmap Image
35 class FXAPI FXPPMImage : public FXImage {
FXDECLARE(FXPPMImage)36   FXDECLARE(FXPPMImage)
37 protected:
38   FXPPMImage(){}
39 private:
40   FXPPMImage(const FXPPMImage&);
41   FXPPMImage &operator=(const FXPPMImage&);
42 public:
43   static const FXchar fileExt[];
44 public:
45 
46   /// Construct icon from memory stream formatted in Portable Pixmap format
47   FXPPMImage(FXApp* a,const void *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
48 
49   /// Save pixels into stream in Portable Pixmap format
50   virtual FXbool savePixels(FXStream& store) const;
51 
52   /// Load pixels from stream in Portable Pixmap format
53   virtual FXbool loadPixels(FXStream& store);
54 
55   /// Destroy icon
56   virtual ~FXPPMImage();
57   };
58 
59 
60 /**
61 * Check if stream contains a PPM, return TRUE if so.
62 */
63 extern FXAPI FXbool fxcheckPPM(FXStream& store);
64 
65 
66 /**
67 * Load an PPM (Portable Pixmap Format) file from a stream.
68 * Upon successful return, the pixel array and size are returned.
69 * If an error occurred, the pixel array is set to NULL.
70 */
71 extern FXAPI FXbool fxloadPPM(FXStream& store,FXColor*& data,FXint& width,FXint& height);
72 
73 
74 /**
75 * Save an PPM (Portable Pixmap Format) file to a stream.
76 */
77 extern FXAPI FXbool fxsavePPM(FXStream& store,const FXColor *data,FXint width,FXint height);
78 
79 }
80 
81 #endif
82