FLTK
Fl_Bitmap.H
1 //
2 // Bitmap header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2017 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 /* \file
18  Fl_Bitmap widget . */
19 
20 #ifndef Fl_Bitmap_H
21 #define Fl_Bitmap_H
22 #include "Fl_Image.H"
23 #include "Fl_Widget.H" // for fl_uintptr_t
24 
25 class Fl_Widget;
26 struct Fl_Menu_Item;
27 
32 class FL_EXPORT Fl_Bitmap : public Fl_Image {
33  friend class Fl_Graphics_Driver;
34 public:
36  const uchar *array;
39 
40 private:
42  fl_uintptr_t id_;
43  int cache_w_, cache_h_; // size of bitmap when cached
44 
45 public:
47  Fl_Bitmap(const uchar *bits, int W, int H) :
48  Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0), cache_w_(0),cache_h_(0) {data((const char **)&array, 1);}
50  Fl_Bitmap(const char *bits, int W, int H) :
51  Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0), cache_w_(0),cache_h_(0) {data((const char **)&array, 1);}
52  virtual ~Fl_Bitmap();
53  virtual Fl_Image *copy(int W, int H);
54  Fl_Image *copy() { return Fl_Image::copy(); }
55  virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
56  void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
57  virtual void label(Fl_Widget*w);
58  virtual void label(Fl_Menu_Item*m);
59  virtual void uncache();
60 };
61 
62 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
int h() const
Returns the current image drawing height in FLTK units.
Definition: Fl_Image.H:132
virtual void label(Fl_Widget *w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item...
Definition: Fl_Image.cxx:130
const char *const * data() const
Returns a pointer to the current image data array.
Definition: Fl_Image.H:163
int alloc_array
Non-zero if array points to bitmap data allocated internally.
Definition: Fl_Bitmap.H:38
Base class for image caching, scaling and drawing.
Definition: Fl_Image.H:62
Fl_Image, Fl_RGB_Image classes.
int w() const
Returns the current image drawing width in FLTK units.
Definition: Fl_Image.H:126
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image to the current drawing surface with a bounding box.
Definition: Fl_Image.cxx:60
Fl_Image * copy()
Creates a copy of the specified image.
Definition: Fl_Image.H:217
opaque fl_uintptr_t
An unsigned integral type large enough to store a pointer or an unsigned long value.
Definition: platform_types.h:33
Fl_Widget, Fl_Label classes .
The Fl_Menu_Item structure defines a single menu item that is used by the Fl_Menu_ class...
Definition: Fl_Menu_Item.H:107
Fl_Bitmap(const char *bits, int W, int H)
The constructors create a new bitmap from the specified bitmap data.
Definition: Fl_Bitmap.H:50
const uchar * array
pointer to raw bitmap data
Definition: Fl_Bitmap.H:36
The Fl_Bitmap class supports caching and drawing of mono-color (bitmap) images.
Definition: Fl_Bitmap.H:32
virtual void uncache()
If the image has been cached for display, delete the cache data.
Definition: Fl_Image.cxx:57
unsigned char uchar
unsigned char
Definition: fl_types.h:28
Fl_Bitmap(const uchar *bits, int W, int H)
The constructors create a new bitmap from the specified bitmap data.
Definition: Fl_Bitmap.H:47