summaryrefslogtreecommitdiff
path: root/src/ps_image.cxx
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 /src/ps_image.cxx
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 'src/ps_image.cxx')
-rw-r--r--src/ps_image.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ps_image.cxx b/src/ps_image.cxx
index 3939a7511..ca71121b9 100644
--- a/src/ps_image.cxx
+++ b/src/ps_image.cxx
@@ -602,6 +602,32 @@ void Fl_PostScript_Graphics_Driver::draw(Fl_RGB_Image * rgb,int XP, int YP, int
mask=0;
}
+int 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 1;
+ 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
+ return 1;
+}
+
+int Fl_PostScript_Graphics_Driver::draw_scaled(Fl_Pixmap *img, 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 1;
+ 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)/img->w(), float(HP)/img->h());
+ draw(img, 0, 0, img->w(), img->h(), 0, 0);
+ clocale_printf("GR GR\n");
+ pop_clip(); // restore FLTK's clip
+ return 1;
+}
+
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;