summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-03-10 21:06:22 +0000
committerManolo Gouy <Manolo>2015-03-10 21:06:22 +0000
commitdbde470f8d9803d6986ff57b7dfcb40d679508b7 (patch)
tree4d7fbeb02dcd207e96922506e6f0a71da796db45 /FL
parentcc2436954d9c281b2a0589e5fc3fe89fa9d4aede (diff)
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
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Device.H12
-rw-r--r--FL/Fl_Image.H1
-rw-r--r--FL/Fl_PostScript.H2
-rw-r--r--FL/Fl_Shared_Image.H22
4 files changed, 34 insertions, 3 deletions
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H
index 7e8d7e5f0..3d86518f3 100644
--- a/FL/Fl_Device.H
+++ b/FL/Fl_Device.H
@@ -402,6 +402,14 @@ public:
inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;}
/** Sets the current Fl_Font_Descriptor for the graphics driver */
inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;}
+#if FLTK_ABI_VERSION >= 10304 || defined(FL_DOXYGEN)
+ virtual
+#endif
+ int draw_scaled(Fl_RGB_Image *img, int X, int Y, int W, int H);
+#if FLTK_ABI_VERSION >= 10304 || defined(FL_DOXYGEN)
+ virtual
+#endif
+ int draw_scaled(Fl_Pixmap *img, int X, int Y, int W, int H);
/** \brief The destructor */
virtual ~Fl_Graphics_Driver() { if (p) free(p); }
};
@@ -428,6 +436,8 @@ public:
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
+ int draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP);
+ int draw_scaled(Fl_Pixmap *img, int XP, int YP, int WP, int HP);
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
@@ -488,6 +498,8 @@ public:
const char *class_name() {return class_id;};
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy);
+ int draw_scaled(Fl_RGB_Image *img, int X, int Y, int W, int H);
+ int draw_scaled(Fl_Pixmap *img, int X, int Y, int W, int H);
};
#endif
#if !(defined(__APPLE__) || defined(WIN32))
diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H
index b00f5678b..1f1ed16bb 100644
--- a/FL/Fl_Image.H
+++ b/FL/Fl_Image.H
@@ -183,6 +183,7 @@ class FL_EXPORT Fl_Image {
class FL_EXPORT Fl_RGB_Image : public Fl_Image {
friend class Fl_Quartz_Graphics_Driver;
friend class Fl_GDI_Graphics_Driver;
+ friend class Fl_GDI_Printer_Graphics_Driver;
friend class Fl_Xlib_Graphics_Driver;
static size_t max_size_;
public:
diff --git a/FL/Fl_PostScript.H b/FL/Fl_PostScript.H
index 8860e331f..19692c455 100644
--- a/FL/Fl_PostScript.H
+++ b/FL/Fl_PostScript.H
@@ -213,6 +213,8 @@ class Clip {
void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
+ int draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP);
+ int draw_scaled(Fl_Pixmap *img, int XP, int YP, int WP, int HP);
int clocale_printf(const char *format, ...);
~Fl_PostScript_Graphics_Driver();
};
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; }
};
//