Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXPNGImage.h
1 /********************************************************************************
2 * *
3 * P N G I m a g e O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXPNGIMAGE_H
22 #define FXPNGIMAGE_H
23 
24 #ifndef FXIMAGE_H
25 #include "FXImage.h"
26 #endif
27 
28 namespace FX {
29 
30 
34 enum {
35  PNG_FILTER_NONE = 0, // No filter
36  PNG_FILTER_SUB = 1, // Sub-filter
37  PNG_FILTER_UP = 2, // Up-filter
38  PNG_FILTER_AVG = 3, // Averaging filter
39  PNG_FILTER_PAETH = 4, // Paeth filter
40  PNG_FILTER_BEST = 5, // Find best filter for each line
41  PNG_COMPRESS_FAST = 8, // Fastest compression
42  PNG_COMPRESS_BEST = 16, // Best compression
43  PNG_IMAGE_GRAY = 32, // Write only one grey channel (blue)
44  PNG_IMAGE_OPAQUE = 64, // Write no alpha alpha channel
45  PNG_IMAGE_ANALYZE = 128, // Analyze image for opacity or alpha
46  PNG_INDEX_COLOR = 256 // Try indexed (colormap) mode
47  };
48 
49 
50 
52 class FXAPI FXPNGImage : public FXImage {
53  FXDECLARE(FXPNGImage)
54 protected:
55  FXuint flags;
56 protected:
57  FXPNGImage(){}
58 private:
59  FXPNGImage(const FXPNGImage&);
60  FXPNGImage &operator=(const FXPNGImage&);
61 public:
62  static const FXchar fileExt[];
63  static const FXchar mimeType[];
64 public:
65 
67  FXPNGImage(FXApp *a,const FXuchar *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1,FXuint fl=PNG_IMAGE_ANALYZE);
68 
70  static const FXbool supported;
71 
73  void setFlags(FXint opts){ options=opts; }
74 
76  FXint getFlags() const { return options; }
77 
79  virtual FXbool savePixels(FXStream& store) const;
80 
82  virtual FXbool loadPixels(FXStream& store);
83 
85  virtual ~FXPNGImage();
86  };
87 
88 
89 
93 extern FXAPI FXbool fxcheckPNG(FXStream& store);
94 
95 
101 extern FXAPI FXbool fxloadPNG(FXStream& store,FXColor*& data,FXint& width,FXint& height);
102 
103 
107 extern FXAPI FXbool fxsavePNG(FXStream& store,const FXColor* data,FXint width,FXint height,FXuint flags=PNG_IMAGE_ANALYZE);
108 
109 }
110 
111 #endif
static const FXbool supported
True if format is supported.
Definition: FXPNGImage.h:70
void setFlags(FXint opts)
Set image save flags.
Definition: FXPNGImage.h:73
FXint getFlags() const
Get image save flags.
Definition: FXPNGImage.h:76
The Application object is the central point of a FOX user-interface.
Definition: FXApp.h:134
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
Definition: FX4Splitter.h:28
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
Portable Network Graphics (PNG) Image class.
Definition: FXPNGImage.h:52

Copyright © 1997-2022 Jeroen van der Zijp