From dbde470f8d9803d6986ff57b7dfcb40d679508b7 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 10 Mar 2015 21:06:22 +0000 Subject: Added Fl_Shared_Image::scale(width, height) to support scaled image drawing (STR #3185). Useful for printing, PostScript or PDF output, or retina displays. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10615 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Shared_Image.H | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'FL/Fl_Shared_Image.H') diff --git a/FL/Fl_Shared_Image.H b/FL/Fl_Shared_Image.H index bcb41219f..5f96f7f2d 100644 --- a/FL/Fl_Shared_Image.H +++ b/FL/Fl_Shared_Image.H @@ -3,7 +3,7 @@ // // Shared image header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2015 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -41,7 +41,12 @@ class FL_EXPORT Fl_Shared_Image : public Fl_Image { friend class Fl_JPEG_Image; friend class Fl_PNG_Image; - + +private: + static Fl_RGB_Scaling scaling_algorithm_; // method used to rescale RGB source images +#if FLTK_ABI_VERSION >= 10304 + Fl_Image *scaled_image_; +#endif protected: static Fl_Shared_Image **images_; // Shared images @@ -66,7 +71,7 @@ protected: void add(); void update(); - public: +public: /** Returns the filename of the shared image */ const char *name() { return name_; } /** Returns the number of references of this shared image. When reference is below 1, the image is deleted. */ @@ -80,14 +85,25 @@ protected: virtual void desaturate(); virtual void draw(int X, int Y, int W, int H, int cx, int cy); void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + void scale(int width, int height, int proportional = 1, int can_expand = 0); virtual void uncache(); static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0); static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0); + static Fl_Shared_Image *get(Fl_RGB_Image *rgb, int own_it = 1); static Fl_Shared_Image **images(); static int num_images(); static void add_handler(Fl_Shared_Handler f); static void remove_handler(Fl_Shared_Handler f); + /** Sets what algorithm is used when resizing a source image. + The default algorithm is FL_RGB_SCALING_BILINEAR. + Drawing an Fl_Shared_Image is sometimes performed by first resizing the source image + and then drawing the resized copy. This occurs, e.g., when drawing to screen under Linux or MSWindows + after having called Fl_Shared_Image::scale(). + This function controls what method is used when the image to be resized is an Fl_RGB_Image. + \version 1.3.4 and requires compiling with FLTK_ABI_VERSION = 10304 + */ + static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; } }; // -- cgit v1.2.3