From cff894183660e222605b945d841a3cb580082201 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 9 Nov 2012 16:02:08 +0000 Subject: Fix STR#2881: the new static function Fl_RGB_Image::max_size(size) allows to control the maximum memory size allowed when creating an Fl_RGB_Image. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9709 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Image.H | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'FL') diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index 61a426054..357982e63 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -23,6 +23,7 @@ # define Fl_Image_H # include "Enumerations.H" +#include class Fl_Widget; struct Fl_Menu_Item; @@ -167,6 +168,7 @@ class FL_EXPORT Fl_RGB_Image : public Fl_Image { friend class Fl_Quartz_Graphics_Driver; friend class Fl_GDI_Graphics_Driver; friend class Fl_Xlib_Graphics_Driver; + static size_t max_size_; public: const uchar *array; @@ -211,6 +213,21 @@ public: virtual void label(Fl_Widget*w); virtual void label(Fl_Menu_Item*m); virtual void uncache(); + /** Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object. + + The image size in bytes of an Fl_RGB_Image object is the value of the product w() * h() * d(). + If this product exceeds size, the created object of a derived class of Fl_RGB_Image + won't be loaded with the image data. + This does not apply to direct RGB image creation with + Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD). + The default max_size() value is essentially infinite. + */ + static void max_size(size_t size) { max_size_ = size;} + /** Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object. + + \sa void Fl_RGB_Image::max_size(size_t) + */ + static size_t max_size() {return max_size_;} }; #endif // !Fl_Image_H -- cgit v1.2.3