Index: FL/Fl_Device.H
===================================================================
--- FL/Fl_Device.H	(revision 10483)
+++ FL/Fl_Device.H	(working copy)
@@ -145,6 +145,7 @@
   friend class Fl_Pixmap;
   friend class Fl_Bitmap;
   friend class Fl_RGB_Image;
+  friend class Fl_Image;
   friend void fl_rect(int x, int y, int w, int h);
   friend void fl_rectf(int x, int y, int w, int h);
   friend void fl_line_style(int style, int width, char* dashes);
@@ -355,7 +356,7 @@
    the image offset by the cx and cy arguments.
    */
   virtual   void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) {}
-  /** \brief Draws an Fl_Pixmap object to the device. 
+  /** \brief Draws an Fl_Pixmap object to the device.
    *
    Specifies a bounding box for the image, with the origin (upper left-hand corner) of 
    the image offset by the cx and cy arguments.
@@ -367,6 +368,10 @@
    the image offset by the cx and cy arguments.
    */
   virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {}
+#if FLTK_ABI_VERSION >= 10304
+  virtual
+#endif
+  void draw_scaled(Fl_RGB_Image *img, int x, int y, int w, int h);
 #if FLTK_ABI_VERSION >= 10301
   virtual
 #endif
@@ -423,6 +428,7 @@
   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);
+  void draw_scaled(Fl_RGB_Image *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);
@@ -483,6 +489,7 @@
   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);
+  void draw_scaled(Fl_RGB_Image *img, int x, int y, int w, int h);
 };
 #endif
 #if !(defined(__APPLE__) || defined(WIN32))
Index: FL/Fl_Image.H
===================================================================
--- FL/Fl_Image.H	(revision 10483)
+++ FL/Fl_Image.H	(working copy)
@@ -160,6 +160,7 @@
     This form specifies the upper-lefthand corner of the image.
   */
   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent
+  void draw_scaled(int X, int Y, int W, int H);
   virtual void uncache();
 
   // set RGB image scaling method
@@ -183,6 +184,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_GDI_Printer_Graphics_Driver;
   friend class Fl_Xlib_Graphics_Driver;
   static size_t max_size_;
 public:
@@ -227,6 +229,7 @@
   virtual void desaturate();
   virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0);
   void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);}
+  void draw_scaled(int X, int Y, int W, int H);
   virtual void label(Fl_Widget*w);
   virtual void label(Fl_Menu_Item*m);
   virtual void uncache();
Index: FL/Fl_PostScript.H
===================================================================
--- FL/Fl_PostScript.H	(revision 10549)
+++ FL/Fl_PostScript.H	(working copy)
@@ -205,6 +205,7 @@
   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);
+  void draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP);
   int clocale_printf(const char *format, ...);
   ~Fl_PostScript_Graphics_Driver();
 };
Index: FL/Fl_Shared_Image.H
===================================================================
--- FL/Fl_Shared_Image.H	(revision 10483)
+++ FL/Fl_Shared_Image.H	(working copy)
@@ -80,6 +80,7 @@
   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 draw_scaled(int X, int Y, int W, int H);
   virtual void uncache();
 
   static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0);
Index: src/Fl_Image.cxx
===================================================================
--- src/Fl_Image.cxx	(revision 10560)
+++ src/Fl_Image.cxx	(working copy)
@@ -23,6 +23,7 @@
 #include <FL/Fl_Menu_Item.H>
 #include <FL/Fl_Image.H>
 #include <FL/Fl_Printer.H>
+#include <FL/Fl_PostScript.H>
 #include "flstring.h"
 
 #ifdef WIN32
@@ -541,6 +542,68 @@
   return 0;
 }
 
+/** Draws the image scaled to width \p w and height \p h with top-left angle at x,y.
+ 
+ Drawing goes to the current surface device.
+ The image can be an Fl_RGB_Image, Fl_Bitmap or Fl_Pixmap.
+ 
+Intended to be mainly useful when printing so the full resolution of images can be
+ accessible to high resolution (e.g., laser printer) or resolution-independent
+ (e.g., PostScript file, PDF printer) devices.
+ \version 1.3.4
+ */
+void Fl_Image::draw_scaled(int x, int y, int w, int h)
+{
+  if (this->w() <= 0 || this->h() <= 0 || w <= 0 || h <= 0) return;
+  if (d() == 0 || count() >= 2) { // handles Fl_Bitmap or Fl_Pixmap
+    Fl_Image *scaled_img = copy(w, h);
+    scaled_img->draw(x, y);
+    delete scaled_img;
+    return;
+  }
+  else {
+    ((Fl_RGB_Image*)this)->Fl_RGB_Image::draw_scaled(x, y, w, h);
+  }
+}
+
+void Fl_RGB_Image::draw_scaled(int x, int y, int w, int h)
+{
+  if (this->w() <= 0 || this->h() <= 0 || w <= 0 || h <= 0) return;
+#if FLTK_ABI_VERSION >= 10304
+    fl_graphics_driver->draw_scaled(this,x,y,w,h);
+#else
+#ifdef WIN32
+    if (fl_graphics_driver->class_name() == Fl_GDI_Printer_Graphics_Driver::class_id) {
+      Fl_GDI_Printer_Graphics_Driver *d = (Fl_GDI_Printer_Graphics_Driver*)fl_graphics_driver;
+      d->Fl_GDI_Printer_Graphics_Driver::draw_scaled(this,x,y,w,h);
+      return;
+    } else
+#elif defined(__APPLE__)
+      if (fl_graphics_driver->class_name() == Fl_Quartz_Graphics_Driver::class_id) {
+        Fl_Quartz_Graphics_Driver *d = (Fl_Quartz_Graphics_Driver*)fl_graphics_driver;
+        d->Fl_Quartz_Graphics_Driver::draw_scaled(this,x,y,w,h);
+        return;
+      } else
+#endif
+        if (fl_graphics_driver->class_name() == Fl_PostScript_Graphics_Driver::class_id) {
+          Fl_PostScript_Graphics_Driver *d = (Fl_PostScript_Graphics_Driver*)fl_graphics_driver;
+          d->Fl_PostScript_Graphics_Driver::draw_scaled(this,x,y,w,h);
+          return;
+        }
+    fl_graphics_driver->Fl_Graphics_Driver::draw_scaled(this,x,y,w,h);
+#endif
+}
+
+
+/** Draws an image scaled
+ */
+void Fl_Graphics_Driver::draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP) {
+  Fl_Image *scaled_img = img->copy(WP, HP);
+  scaled_img->draw(XP, YP);
+  delete scaled_img;
+}
+
+
 #ifdef __APPLE__
 static void imgProviderReleaseData (void *info, const void *data, size_t size)
 {
@@ -594,6 +657,21 @@
   }
 }
 
+void Fl_Quartz_Graphics_Driver::draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP) {
+  int X, Y, W, H;
+  fl_clip_box(XP,YP,WP,HP,X,Y,W,H); // X,Y,W,H will give the unclipped area of XP,YP,WP,HP
+  if (W == 0 || H == 0) return;
+  fl_push_no_clip(); // remove the FLTK clip that can't be rescaled
+  CGContextSaveGState(fl_gc);
+  CGContextClipToRect(fl_gc, CGRectMake(X, Y, W, H)); // this clip path will be rescaled & translated
+  CGContextTranslateCTM(fl_gc, XP, YP);
+  CGContextScaleCTM(fl_gc, float(WP)/img->w(), float(HP)/img->h());
+  draw(img, 0, 0, img->w(), img->h(), 0, 0);
+  CGContextRestoreGState(fl_gc);
+  fl_pop_clip(); // restore FLTK's clip
+}
+
+
 #elif defined(WIN32)
 void Fl_GDI_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
   int X, Y, W, H;
@@ -636,6 +714,38 @@
   }
 }
 
+void Fl_GDI_Printer_Graphics_Driver::draw_scaled(Fl_RGB_Image *img, int XP, int YP, int WP, int HP) {
+  // Don't draw an empty image...
+  if (!img->d() || !img->array) {
+    push_clip(XP, YP, WP, HP);
+    img->draw_empty(XP, YP);
+    pop_clip();
+    return;
+  }
+  if (!img->id_) {
+    img->id_ = fl_create_offscreen(img->w(), img->h());
+    if ((img->d() == 2 || img->d() == 4) && fl_can_do_alpha_blending()) {
+      fl_begin_offscreen((Fl_Offscreen)img->id_);
+      fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d()|FL_IMAGE_WITH_ALPHA, img->ld());
+      fl_end_offscreen();
+    } else {
+      fl_begin_offscreen((Fl_Offscreen)img->id_);
+      fl_draw_image(img->array, 0, 0, img->w(), img->h(), img->d(), img->ld());
+      fl_end_offscreen();
+      if (img->d() == 2 || img->d() == 4) {
+        img->mask_ = fl_create_alphamask(img->w(), img->h(), img->d(), img->ld(), img->array);
+      }
+    }
+  }
+  HDC new_gc = CreateCompatibleDC(fl_gc);
+  int save = SaveDC(new_gc);
+  SelectObject(new_gc, (void*)img->id_);
+  StretchBlt(fl_gc, XP, YP, WP, HP, new_gc, 0, 0, img->w(), img->h(), SRCCOPY);
+  RestoreDC(new_gc, save);
+  DeleteDC(new_gc);
+}
+
+
 #else
 void Fl_Xlib_Graphics_Driver::draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy) {
   int X, Y, W, H;
Index: src/Fl_Shared_Image.cxx
===================================================================
--- src/Fl_Shared_Image.cxx	(revision 10483)
+++ src/Fl_Shared_Image.cxx	(working copy)
@@ -461,7 +461,12 @@
   }
 }
 
+void Fl_Shared_Image::draw_scaled(int X, int Y, int W, int H)
+{
+  image_->draw_scaled(X, Y, W, H);
+}
 
+
 //
 // End of "$Id$".
 //
Index: src/ps_image.cxx
===================================================================
--- src/ps_image.cxx	(revision 10483)
+++ src/ps_image.cxx	(working copy)
@@ -456,6 +456,18 @@
   mask=0;
 }
 
+void Fl_PostScript_Graphics_Driver::draw_scaled(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP){
+  int X, Y, W, H;
+  clip_box(XP,YP,WP,HP,X,Y,W,H); // X,Y,W,H will give the unclipped area of XP,YP,WP,HP
+  if (W == 0 || H == 0) return;
+  push_no_clip(); // remove the FLTK clip that can't be rescaled
+  clocale_printf("%d %d %i %i CL\n", X, Y, W, H);
+  clocale_printf("GS %d %d TR  %f %f SC GS\n", XP, YP, float(WP)/rgb->w(), float(HP)/rgb->h());
+  draw(rgb, 0, 0, rgb->w(), rgb->h(), 0, 0);
+  clocale_printf("GR GR\n");
+  pop_clip(); // restore FLTK's clip
+}
+
 void Fl_PostScript_Graphics_Driver::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){
   const uchar  * di = bitmap->array;
   int w,h;
Index: test/pixmap_browser.cxx
===================================================================
--- test/pixmap_browser.cxx	(revision 10483)
+++ test/pixmap_browser.cxx	(working copy)
@@ -3,7 +3,7 @@
 //
 // A shared image test program 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
@@ -21,18 +21,53 @@
 #include <FL/Fl_Double_Window.H>
 #include <FL/Fl_Button.H>
 #include <FL/Fl_Shared_Image.H>
+#include <FL/Fl_Printer.H>
+#include <FL/fl_draw.H>
 #include <string.h>
 #include <errno.h>
 #include <FL/Fl_File_Chooser.H>
 #include <FL/fl_message.H>
 
-Fl_Box *b;
 Fl_Double_Window *w;
 Fl_Shared_Image *img;
+Fl_Check_Button *prop_button;
 
 
 static char name[1024];
 
+
+class centered_image : public Fl_Widget {
+  Fl_Shared_Image *img;
+public:
+  centered_image(int x, int y, int w, int h) : Fl_Widget(x,y,w,h) {
+    img = NULL;
+    box(FL_DOWN_BOX);
+  }
+  void image(Fl_Shared_Image *i) {
+    img = i;
+  }
+  void draw() {
+    draw_box();
+    if (!img) return;
+    float fw = img->w() / float(w());
+    float fh = img->h() / float(h());
+    if (fw < 1) fw = 1;
+    if (fh < 1) fh = 1;
+    if (prop_button->value()) {
+      if (fh > fw) fw = fh;
+      else fh = fw;
+    }
+    int xx = (w() - img->w()/fw)/2;
+    int yy = (h() - img->h()/fh)/2;
+    fl_color(FL_BLACK);
+    if (fw > 1 || fh > 1) img->draw_scaled(x() + xx, y() + yy, img->w()/fw, img->h()/fh);
+    else img->draw(x() + xx, y() + yy);
+  }
+};
+
+centered_image *b;
+
+
 void load_file(const char *n) {
   if (img) {
     img->release();
@@ -46,8 +81,8 @@
     b->redraw();
     return;
   }
-  img = Fl_Shared_Image::get(n);
-  if (!img) {
+  Fl_Shared_Image *img2 = Fl_Shared_Image::get(n);
+  if (!img2) {
     b->label("@filenew"); // show an empty document
     b->labelsize(64);
     b->labelcolor(FL_LIGHT2);
@@ -55,15 +90,8 @@
     b->redraw();
     return;
   }
-  if (img->w() > b->w() || img->h() > b->h()) {
-    Fl_Image *temp;
-    if (img->w() > img->h()) temp = img->copy(b->w(), b->h() * img->h() / img->w());
-    else temp = img->copy(b->w() * img->w() / img->h(), b->h());
-
-    img->release();
-    img = (Fl_Shared_Image *)temp;
-  }
-  b->label(name);
+  if (img) img->release();
+  img = img2;
   b->labelsize(14);
   b->labelcolor(FL_FOREGROUND_COLOR);
   b->image(img);
@@ -84,6 +112,21 @@
   fl_file_chooser_callback(0);
 }
 
+void print_cb(Fl_Widget *widget, void *) {
+  Fl_Printer printer;
+  int width, height;
+  printer.start_job(1);
+  printer.start_page();
+  printer.printable_rect(&width, &height);
+  float fw = widget->window()->decorated_w() / float(width);
+  float fh = widget->window()->decorated_h() / float(height);
+  if (fh > fw) fw = fh;
+  printer.scale(1/fw);
+  printer.print_window(widget->window());
+  printer.end_page();
+  printer.end_job();
+}
+
 int dvisual = 0;
 int arg(int, char **argv, int &i) {
   if (argv[i][1] == '8') {dvisual = 1; i++; return 1;}
@@ -97,15 +140,20 @@
 
   Fl::args(argc,argv,i,arg);
 
-  Fl_Double_Window window(400,435); ::w = &window;
-  Fl_Box b(10,45,380,380); ::b = &b;
+  Fl_Double_Window window(400,450); ::w = &window;
+  centered_image b(10,45,380,380); ::b = &b;
   b.box(FL_THIN_DOWN_BOX);
   b.align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
   Fl_Button button(150,5,100,30,"load");
   button.callback(button_cb);
   if (!dvisual) Fl::visual(FL_RGB);
   if (argv[1]) load_file(argv[1]);
-  window.resizable(window);
+  window.resizable(b);
+  prop_button = new Fl_Check_Button(10, 430, 140, 15, "Proportional resize");
+  prop_button->value(1);
+  Fl_Button print(300,425,50,25,"Print");
+  print.callback(print_cb);
+
   window.show(argc,argv);
   return Fl::run();
 }
