FLTK 1.3.9: Fl_Image_Surface Class Reference

FLTK 1.3.9

Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
Fl_Image_Surface Class Reference

Directs all graphics requests to an Fl_Image. More...

`#include <Fl_Image_Surface.H>`

Inheritance diagram for Fl_Image_Surface:

## Public Member Functions
const char * | class_name ()
| Returns the name of the class of this object.
void | draw (Fl_Widget *, int delta_x=0, int delta_y=0)
| Draws a widget in the image surface.
void | draw_decorated_window (Fl_Window *win, int delta_x=0, int delta_y=0)
| Draws a window and its borders and title bar to the image drawing surface.
| Fl_Image_Surface (int w, int h, int highres=0)
| Constructor with optional high resolution.
Fl_Shared_Image * | highres_image ()
| Returns a possibly high resolution image made of all drawings sent to the Fl_Image_Surface object.
Fl_RGB_Image * | image ()
| Returns an image made of all drawings sent to the Fl_Image_Surface object.
void | set_current ()
| Make this surface the current drawing surface.
| ~Fl_Image_Surface ()
| The destructor.
Public Member Functions inherited from Fl_Surface_Device
const char * | class_name ()
| Returns the name of the class of this object.
Fl_Graphics_Driver * | driver ()
| Returns the graphics driver of this drawing surface.
void | driver (Fl_Graphics_Driver *graphics_driver)
| Sets the graphics driver of this drawing surface.
virtual void | set_current (void)
| Make this surface the current drawing surface.
virtual | ~Fl_Surface_Device ()
| The destructor.
Public Member Functions inherited from Fl_Device
virtual const char * | class_name ()
| Returns the name of the class of this object.
virtual | ~Fl_Device ()
| Virtual destructor.

## Static Public Attributes
static const char * | class_id = "Fl_Image_Surface"
Static Public Attributes inherited from Fl_Surface_Device
static const char * | class_id = "Fl_Surface_Device"
Static Public Attributes inherited from Fl_Device
static const char * | class_id = "Fl_Device"
| A string that identifies each subclass of Fl_Device.

## Additional Inherited Members
Static Public Member Functions inherited from Fl_Surface_Device
static Fl_Surface_Device * | surface ()
| The current drawing surface.
Protected Member Functions inherited from Fl_Surface_Device
| Fl_Surface_Device (Fl_Graphics_Driver *graphics_driver)
| Constructor that sets the graphics driver to use for the created surface.

## Detailed Description

Directs all graphics requests to an Fl_Image.

After creation of an Fl_Image_Surface object, call set_current() on it, and all subsequent graphics requests will be recorded in the image. It's possible to draw widgets (using Fl_Image_Surface::draw()) or to use any of the Drawing functions or the Color & Font functions. Finally, call image() on the object to obtain a newly allocated Fl_RGB_Image object.
Fl_GL_Window objects can be drawn in the image as well.

Usage example:

Fl_Widget *g = ...; // a widget you want to draw in an image
Fl_Image_Surface *img_surf = new Fl_Image_Surface(g->w(), g->h()); // create an Fl_Image_Surface object
img_surf->set_current(); // direct graphics requests to the image
fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background
img_surf->draw(g); // draw the g widget in the image
Fl_RGB_Image* image = img_surf->image(); // get the resulting image
delete img_surf; // delete the img_surf object
Fl_Display_Device::display_device()->set_current(); // direct graphics requests back to the display
Fl_Display_Device::display_device
static Fl_Display_Device * display_device()
Returns the platform display device.
Definition Fl_Device.cxx:83
Fl_Image_Surface
Directs all graphics requests to an Fl_Image.
Definition Fl_Image_Surface.H:47
Fl_Image_Surface::draw
void draw(Fl_Widget *, int delta_x=0, int delta_y=0)
Draws a widget in the image surface.
Definition Fl_Image_Surface.cxx:152
Fl_Image_Surface::set_current
void set_current()
Make this surface the current drawing surface.
Definition Fl_Image_Surface.cxx:158
Fl_Image_Surface::image
Fl_RGB_Image * image()
Returns an image made of all drawings sent to the Fl_Image_Surface object.
Definition Fl_Image_Surface.cxx:103
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:202
Fl_Surface_Device::set_current
virtual void set_current(void)
Make this surface the current drawing surface.
Definition Fl_Device.cxx:44
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:101
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:143
Fl_Widget::h
void h(int v)
Internal use only.
Definition Fl_Widget.H:145
fl_color
Fl_Color fl_color()
Returns the last fl_color() that was set.
Definition fl_draw.H:70
fl_rectf
void fl_rectf(int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
Definition fl_draw.H:206

## Constructor & Destructor Documentation

## ◆ Fl_Image_Surface()

Fl_Image_Surface::Fl_Image_Surface | ( | int | w,
|  | int | h,
|  | int | highres = `0`
| ) |  |

Constructor with optional high resolution.

Parameters

  w | and
  h | give the size in pixels of the resulting image.
  highres | if non-zero, the surface pixel size is twice as high and wide as w and h, which is useful to draw it later on a high resolution display (e.g., retina display). This is implemented for the Mac OS platform only. If `highres` is non-zero, use Fl_Image_Surface::highres_image() to get the image data.

Version
  1.3.4 and requires compilation with -DFL_ABI_VERSION=10304 (1.3.3 without the highres parameter)

## Member Function Documentation

## ◆ class_name()

const char * Fl_Image_Surface::class_name | ( |  | ) |
| inlinevirtual

Returns the name of the class of this object.

Use of the class_name() function is discouraged because it will be removed from future FLTK versions.

The class of an instance of an Fl_Device subclass can be checked with code such as:

if ( instance->class_name() == Fl_Printer::class_id ) { ... }

Reimplemented from Fl_Device.

## ◆ draw()

void Fl_Image_Surface::draw | ( | Fl_Widget * | widget,
|  | int | delta_x = `0`,
|  | int | delta_y = `0`
| ) |  |

Draws a widget in the image surface.

Parameters

  widget | any FLTK widget (e.g., standard, custom, window, GL view) to draw in the image
  delta_x | and
  delta_y | give the position in the image of the top-left corner of the widget

## ◆ draw_decorated_window()

void Fl_Image_Surface::draw_decorated_window | ( | Fl_Window * | win,
|  | int | delta_x = `0`,
|  | int | delta_y = `0`
| ) |  |

Draws a window and its borders and title bar to the image drawing surface.

Parameters

  win | an FLTK window to draw in the image
  delta_x | and
  delta_y | give the position in the image of the top-left corner of the window's title bar

## ◆ highres_image()

Fl_Shared_Image * Fl_Image_Surface::highres_image | ( |  | ) |

Returns a possibly high resolution image made of all drawings sent to the Fl_Image_Surface object.

The Fl_Image_Surface object should have been constructed with Fl_Image_Surface(W, H, 1). The returned image is scaled to a size of WxH drawing units and may have a pixel size twice as wide and high. The returned object should be deallocated with Fl_Shared_Image::release() after use.

Version
  1.3.4 and requires compilation with -DFL_ABI_VERSION=10304

## ◆ image()

Fl_RGB_Image * Fl_Image_Surface::image | ( |  | ) |

Returns an image made of all drawings sent to the Fl_Image_Surface object.

The returned object contains its own copy of the RGB data. Prefer Fl_Image_Surface::highres_image() if the surface was constructed with the highres option on.

## ◆ set_current()

void Fl_Image_Surface::set_current | ( | void |  | ) |
| virtual

Make this surface the current drawing surface.

This surface will receive all future graphics requests.

Reimplemented from Fl_Surface_Device.

The documentation for this class was generated from the following files:

- Fl_Image_Surface.H
- Fl_Image_Surface.cxx