FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_SVG_Image.H
1//
2// SVG Image header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 2017-2022 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
22struct NSVGimage;
23
135class FL_EXPORT Fl_SVG_Image : public Fl_RGB_Image {
136private:
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 cache_size_(int &width, int &height) FL_OVERRIDE;
150 void init_(const char *name, const unsigned char *filedata, size_t length);
151 Fl_SVG_Image(const Fl_SVG_Image *source);
152public:
156 Fl_SVG_Image(const char *filename);
157 Fl_SVG_Image(const char *sharedname, const char *svg_data);
158 Fl_SVG_Image(const char *sharedname, const unsigned char *svg_data, size_t length);
159 virtual ~Fl_SVG_Image();
160 Fl_Image *copy(int W, int H) const FL_OVERRIDE;
161 Fl_Image *copy() const {
162 return Fl_Image::copy();
163 }
164 void resize(int width, int height);
165 void desaturate() FL_OVERRIDE;
166 void color_average(Fl_Color c, float i) FL_OVERRIDE;
167 void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0) FL_OVERRIDE;
168 void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); }
170 void normalize() FL_OVERRIDE;
171};
172
173#endif // FL_SVG_IMAGE_H
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
Fl_Image, Fl_RGB_Image classes.
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
int w() const
Returns the current image drawing width in FLTK units.
Definition Fl_Image.H:131
Fl_Image * copy() const
Creates a copy of the image in the same size.
Definition Fl_Image.H:266
int h() const
Returns the current image drawing height in FLTK units.
Definition Fl_Image.H:137
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:339
void draw(int X, int Y, int W, int H, int cx=0, int cy=0) FL_OVERRIDE
Draws the image to the current drawing surface with a bounding box.
Definition Fl_Image.cxx:708
void desaturate() FL_OVERRIDE
The desaturate() method converts an image to grayscale.
Definition Fl_Image.cxx:669
virtual void normalize()
Makes sure the object is fully initialized.
Definition Fl_Image.H:394
The Fl_SVG_Image class supports loading, caching and drawing of scalable vector graphics (SVG) images...
Definition Fl_SVG_Image.H:135
bool proportional
Set this to false to allow image re-scaling that alters the image aspect ratio.
Definition Fl_SVG_Image.H:155
Fl_SVG_Image * as_svg_image() FL_OVERRIDE
Returns whether an image is an Fl_SVG_Image or not.
Definition Fl_SVG_Image.H:169
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46