Make Fl_Image::copy() 'const', including all derived classes

Copying an image does not (and must not) change the original object,
hence copy() should always be 'const'.

This is *necessary* if the given Fl_Image object is 'const'.
This commit is contained in:
Albrecht Schlosser
2022-03-20 19:59:22 +01:00
parent 95b5623b96
commit 10537b7143
9 changed files with 48 additions and 22 deletions
+4 -4
View File
@@ -234,7 +234,7 @@ public:
Fl_Image(int W, int H, int D);
virtual ~Fl_Image();
virtual Fl_Image *copy(int W, int H);
virtual Fl_Image *copy(int W, int H) const;
/**
Creates a copy of the specified image.
The image should be released when you are done with it.
@@ -247,7 +247,7 @@ public:
\see Fl_Image::release()
\see Fl_Image::copy(int w, int h)
*/
Fl_Image *copy() { return copy(w(), h()); }
Fl_Image *copy() const { return copy(w(), h()); }
virtual void color_average(Fl_Color c, float i);
/**
The inactive() method calls
@@ -340,8 +340,8 @@ public:
Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0);
Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY);
virtual ~Fl_RGB_Image();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return Fl_Image::copy(); }
virtual Fl_Image *copy(int W, int H) const;
Fl_Image *copy() const { return Fl_Image::copy(); }
virtual void color_average(Fl_Color c, float i);
virtual void desaturate();
virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
+6 -4
View File
@@ -147,16 +147,18 @@ private:
float svg_scaling_(int W, int H);
void rasterize_(int W, int H);
virtual void cache_size_(int &width, int &height);
void init_(const char *filename, const char *filedata, Fl_SVG_Image *copy_source);
Fl_SVG_Image(Fl_SVG_Image *source);
void init_(const char *filename, const char *filedata, const Fl_SVG_Image *copy_source);
Fl_SVG_Image(const Fl_SVG_Image *source);
public:
/** Set this to \c false to allow image re-scaling that alters the image aspect ratio.
Upon object creation, proportional is set to \c true, and the aspect ratio is kept constant.*/
bool proportional;
Fl_SVG_Image(const char *filename, const char *svg_data = NULL);
virtual ~Fl_SVG_Image();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return Fl_Image::copy(); }
virtual Fl_Image *copy(int W, int H) const;
Fl_Image *copy() const {
return Fl_Image::copy();
}
void resize(int width, int height);
virtual void desaturate();
virtual void color_average(Fl_Color c, float i);
+4 -2
View File
@@ -145,8 +145,10 @@ public:
return this;
}
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return Fl_Image::copy(); }
virtual Fl_Image *copy(int W, int H) const;
Fl_Image *copy() const {
return Fl_Image::copy();
}
virtual void color_average(Fl_Color c, float i);
virtual void desaturate();
virtual void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0);
+4 -2
View File
@@ -40,8 +40,10 @@ class FL_EXPORT Fl_Tiled_Image : public Fl_Image {
Fl_Tiled_Image(Fl_Image *i, int W = 0, int H = 0);
virtual ~Fl_Tiled_Image();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return Fl_Image::copy(); }
virtual Fl_Image *copy(int W, int H) const;
Fl_Image *copy() const {
return Fl_Image::copy();
}
virtual void color_average(Fl_Color c, float i);
virtual void desaturate();
virtual void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0);