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

FXBitmap.h
1 /********************************************************************************
2 * *
3 * B i t m a p O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2017 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 FXBITMAP_H
22 #define FXBITMAP_H
23 
24 #ifndef FXDRAWABLE_H
25 #include "FXDrawable.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 // Image rendering hints
32 enum {
33  BITMAP_KEEP = 0x00000001, // Keep pixel data in client
34  BITMAP_OWNED = 0x00000002, // Pixel data is owned by image
35  BITMAP_SHMI = 0x00000020, // Using shared memory image
36  BITMAP_SHMP = 0x00000040 // Using shared memory pixmap
37  };
38 
39 
40 // Forward declarations
41 class FXDC;
42 class FXDCWindow;
43 
44 
55 class FXAPI FXBitmap : public FXDrawable {
56  FXDECLARE(FXBitmap)
57  friend class FXDC;
58  friend class FXDCWindow;
59 private:
60 #ifdef WIN32
61  virtual FXID GetDC() const;
62  virtual int ReleaseDC(FXID) const;
63 #endif
64 protected:
65  FXuchar *data; // Pixel data
66  FXint bytewidth; // Number of bytes across
67  FXuint options; // Options
68 protected:
69  FXBitmap();
70 private:
71  FXBitmap(const FXBitmap&);
72  FXBitmap &operator=(const FXBitmap&);
73 public:
74 
84  FXBitmap(FXApp* a,const void *pix=NULL,FXuint opts=0,FXint w=1,FXint h=1);
85 
87  void setOptions(FXuint opts);
88 
90  FXuint getOptions() const { return options; }
91 
93  void setOwned(FXbool owned);
94 
96  FXbool isOwned() const;
97 
104  virtual void setData(FXuchar *pix,FXuint opts=0);
105 
112  virtual void setData(FXuchar *pix,FXuint opts,FXint w,FXint h);
113 
115  FXuchar* getData() const { return data; }
116 
118  FXbool getPixel(FXint x,FXint y) const { return (FXbool)((data[y*bytewidth+(x>>3)]>>(x&7))&1); }
119 
121  void setPixel(FXint x,FXint y,FXbool color){ color ? data[y*bytewidth+(x>>3)]|=(1<<(x&7)) : data[y*bytewidth+(x>>3)]&=~(1<<(x&7)); }
122 
130  virtual void create();
131 
136  virtual void detach();
137 
142  virtual void destroy();
143 
147  virtual void restore();
148 
153  virtual void render();
154 
159  virtual void release();
160 
166  virtual void resize(FXint w,FXint h);
167 
172  virtual void scale(FXint w,FXint h);
173 
175  virtual void mirror(FXbool horizontal,FXbool vertical);
176 
178  virtual void rotate(FXint degrees);
179 
186  virtual void crop(FXint x,FXint y,FXint w,FXint h,FXbool color=false);
187 
189  virtual void fill(FXbool color);
190 
192  virtual void save(FXStream& store) const;
193 
195  virtual void load(FXStream& store);
196 
198  virtual FXbool savePixels(FXStream& store) const;
199 
201  virtual FXbool loadPixels(FXStream& store);
202 
204  virtual ~FXBitmap();
205  };
206 
207 }
208 
209 #endif
210 

Copyright © 1997-2016 Jeroen van der Zijp