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

FXImage.h
1 /********************************************************************************
2 * *
3 * I m a g e O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,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 FXIMAGE_H
22 #define FXIMAGE_H
23 
24 #ifndef FXDRAWABLE_H
25 #include "FXDrawable.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  IMAGE_KEEP = 0x00000001,
34  IMAGE_OWNED = 0x00000002,
35  IMAGE_DITHER = 0,
36  IMAGE_NEAREST = 0x00000004,
37  IMAGE_OPAQUE = 0x00000008,
38  IMAGE_ALPHACOLOR = 0x00000010,
39  IMAGE_SHMI = 0x00000020,
40  IMAGE_SHMP = 0x00000040,
41  IMAGE_ALPHAGUESS = 0x00000080,
42  IMAGE_THRESGUESS = 0x00000100
43  };
44 
45 
46 class FXDC;
47 class FXDCWindow;
48 
49 
67 class FXAPI FXImage : public FXDrawable {
68  FXDECLARE(FXImage)
69  friend class FXDC;
70  friend class FXDCWindow;
71 protected:
72  FXColor *data; // Pixel data
73  FXuint options; // Options
74 private:
75 #ifdef WIN32
76  virtual FXID GetDC() const;
77  virtual int ReleaseDC(FXID) const;
78 #else
79  void render_true_32(void *xim,FXuchar *img);
80  void render_true_24(void *xim,FXuchar *img);
81  void render_true_16_fast(void *xim,FXuchar *img);
82  void render_true_16_dither(void *xim,FXuchar *img);
83  void render_true_8_fast(void *xim,FXuchar *img);
84  void render_true_8_dither(void *xim,FXuchar *img);
85  void render_true_N_fast(void *xim,FXuchar *img);
86  void render_true_N_dither(void *xim,FXuchar *img);
87  void render_index_4_fast(void *xim,FXuchar *img);
88  void render_index_4_dither(void *xim,FXuchar *img);
89  void render_index_8_fast(void *xim,FXuchar *img);
90  void render_index_8_dither(void *xim,FXuchar *img);
91  void render_index_N_fast(void *xim,FXuchar *img);
92  void render_index_N_dither(void *xim,FXuchar *img);
93  void render_gray_8_fast(void *xim,FXuchar *img);
94  void render_gray_8_dither(void *xim,FXuchar *img);
95  void render_gray_N_fast(void *xim,FXuchar *img);
96  void render_gray_N_dither(void *xim,FXuchar *img);
97  void render_mono_1_fast(void *xim,FXuchar *img);
98  void render_mono_1_dither(void *xim,FXuchar *img);
99 #endif
100 protected:
101  FXImage();
102 private:
103  FXImage(const FXImage&);
104  FXImage &operator=(const FXImage&);
105 public:
106 
116  FXImage(FXApp* a,const FXColor *pix=nullptr,FXuint opts=0,FXint w=1,FXint h=1);
117 
119  void setOptions(FXuint opts);
120 
122  FXuint getOptions() const { return options; }
123 
125  void setOwned(FXbool owned);
126 
128  FXbool isOwned() const;
129 
136  virtual void setData(FXColor *pix,FXuint opts=0);
137 
144  virtual void setData(FXColor *pix,FXuint opts,FXint w,FXint h);
145 
147  FXColor* getData() const { return data; }
148 
150  FXColor getPixel(FXint x,FXint y) const { return data[y*width+x]; }
151 
153  void setPixel(FXint x,FXint y,FXColor color){ data[y*width+x]=color; }
154 
156  FXbool hasAlpha() const;
157 
166  virtual void create();
167 
172  virtual void detach();
173 
178  virtual void destroy();
179 
185  virtual void restore();
186 
194  virtual void render();
195 
200  virtual void release();
201 
207  virtual void resize(FXint w,FXint h);
208 
213  virtual void scale(FXint w,FXint h,FXint quality=0);
214 
216  virtual void mirror(FXbool horizontal,FXbool vertical);
217 
222  virtual void rotate(FXint degrees);
223 
230  virtual void crop(FXint x,FXint y,FXint w,FXint h,FXColor color=0);
231 
233  virtual void fill(FXColor color);
234 
236  virtual void fade(FXColor color,FXint factor=255);
237 
243  virtual void xshear(FXint shear,FXColor clr=0);
244 
250  virtual void yshear(FXint shear,FXColor clr=0);
251 
253  virtual void hgradient(FXColor left,FXColor right);
254 
256  virtual void vgradient(FXColor top,FXColor bottom);
257 
259  virtual void gradient(FXColor topleft,FXColor topright,FXColor bottomleft,FXColor bottomright);
260 
262  virtual void blend(FXColor color);
263 
265  virtual void invert();
266 
268  virtual void colorize(FXColor color);
269 
271  virtual FXbool savePixels(FXStream& store) const;
272 
274  virtual FXbool loadPixels(FXStream& store);
275 
277  virtual void save(FXStream& store) const;
278 
280  virtual void load(FXStream& store);
281 
283  virtual ~FXImage();
284  };
285 
286 }
287 
288 #endif
void setPixel(FXint x, FXint y, FXColor color)
Change pixel at x,y.
Definition: FXImage.h:153
FXColor * getData() const
Return pointer to the pixel data of the image.
Definition: FXImage.h:147
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
Abstract Device Context.
Definition: FXDC.h:153
Definition: FX4Splitter.h:28
FXColor getPixel(FXint x, FXint y) const
Get pixel at x,y.
Definition: FXImage.h:150
Window Device Context.
Definition: FXDCWindow.h:48
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
FXuint getOptions() const
To get to the option flags.
Definition: FXImage.h:122
Drawable is an abstract base class for any surface that can be drawn upon, such as a FXWindow...
Definition: FXDrawable.h:38

Copyright © 1997-2022 Jeroen van der Zijp