FLTK
Fl_SVG_Image.H
1 //
2 // SVG Image header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 2017-2020 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 #ifndef FL_SVG_IMAGE_H
18 #define FL_SVG_IMAGE_H
19 
20 #include <FL/Fl_Image.H>
21 
22 struct NSVGimage;
23 
135 class FL_EXPORT Fl_SVG_Image : public Fl_RGB_Image {
136 private:
137  typedef struct {
138  NSVGimage* svg_image;
139  int ref_count;
140  } counted_NSVGimage;
141  counted_NSVGimage* counted_svg_image_;
142  bool rasterized_;
143  int raster_w_, raster_h_;
144  bool to_desaturate_;
145  Fl_Color average_color_;
146  float average_weight_;
147  float svg_scaling_(int W, int H);
148  void rasterize_(int W, int H);
149  void init_(const char *filename, const char *filedata, Fl_SVG_Image *copy_source);
150  Fl_SVG_Image(Fl_SVG_Image *source);
151 public:
155  Fl_SVG_Image(const char *filename, const char *svg_data = NULL);
156  virtual ~Fl_SVG_Image();
157  virtual Fl_Image *copy(int W, int H);
158  Fl_Image *copy() { return Fl_Image::copy(); }
159  void resize(int width, int height);
160  virtual void desaturate();
161  virtual void color_average(Fl_Color c, float i);
162  virtual void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0);
163  void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
164  virtual Fl_SVG_Image *as_svg_image() { return this; };
165  virtual void normalize();
166 };
167 
168 #endif // FL_SVG_IMAGE_H
virtual Fl_SVG_Image * as_svg_image()
Returns whether an image is an Fl_SVG_Image or not.
Definition: Fl_SVG_Image.H:164
int h() const
Returns the current image drawing height in FLTK units.
Definition: Fl_Image.H:132
virtual void normalize()
Makes sure the object is fully initialized.
Definition: Fl_Image.H:340
The Fl_SVG_Image class supports loading, caching and drawing of scalable vector graphics (SVG) images...
Definition: Fl_SVG_Image.H:135
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
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:287
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:643
Fl_Image * copy()
Creates a copy of the specified image.
Definition: Fl_Image.H:217
virtual void color_average(Fl_Color c, float i)
The color_average() method averages the colors in the image with the FLTK color value c...
Definition: Fl_Image.cxx:545
virtual void desaturate()
The desaturate() method converts an image to grayscale.
Definition: Fl_Image.cxx:604
bool proportional
Set this to false to allow image re-scaling that alters the image aspect ratio.
Definition: Fl_SVG_Image.H:154
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:1042