FLTK 1.4.4: Fl_SVG_Image.H Source File

FLTK 1.4.4

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
135 class 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:
155 bool proportional;
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); }
169 Fl_SVG_Image *as_svg_image() FL_OVERRIDE { return this; }
170 void normalize() FL_OVERRIDE;
171};
172
173#endif // FL_SVG_IMAGE_H
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
Fl_Image::w
int w() const
Returns the current image drawing width in FLTK units.
Definition Fl_Image.H:131
Fl_Image::copy
Fl_Image * copy() const
Creates a copy of the image in the same size.
Definition Fl_Image.H:266
Fl_Image::h
int h() const
Returns the current image drawing height in FLTK units.
Definition Fl_Image.H:137
Fl_RGB_Image::draw
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:728
Fl_RGB_Image::Fl_RGB_Image
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0)
The constructor creates a new image from the specified data.
Definition Fl_Image.cxx:374
Fl_RGB_Image::desaturate
void desaturate() FL_OVERRIDE
The desaturate() method converts an image to grayscale.
Definition Fl_Image.cxx:673
Fl_RGB_Image::normalize
virtual void normalize()
Makes sure the object is fully initialized.
Definition Fl_Image.H:394
Fl_SVG_Image::proportional
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_SVG_Image * as_svg_image() FL_OVERRIDE
Returns whether an image is an Fl_SVG_Image or not.
Definition Fl_SVG_Image.H:169
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46