From 7847c2d87ab85b54f846f8ab240b5e866e9a6593 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 7 Jul 2017 14:31:40 +0000 Subject: WIN32 HiDPI support: fix copy and paste of image data when rescaling is applied. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12297 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- examples/clipboard.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/clipboard.cxx b/examples/clipboard.cxx index f21586367..156c520d2 100644 --- a/examples/clipboard.cxx +++ b/examples/clipboard.cxx @@ -37,6 +37,9 @@ Fl_Box *image_box; Fl_Box *image_size; Fl_Text_Display *display; +inline int fl_min(int a, int b) { return (a < b ? a : b); } + + class chess : public Fl_Box { // a box with a chess-like pattern below its image public: chess(int x, int y, int w, int h) : Fl_Box(FL_FLAT_BOX,x,y,w,h,0) { @@ -95,8 +98,11 @@ public: #endif Fl_Shared_Image *oldim = (Fl_Shared_Image*)image_box->image(); if (oldim) oldim->release(); + float scale = fl_graphics_driver->scale(); Fl_Shared_Image *shared = Fl_Shared_Image::get(im); - shared->scale(image_box->w(), image_box->h()); + int width = fl_min(image_box->w(), im->w()/scale); + int height = fl_min(image_box->h(), im->h()/scale); + shared->scale(width, height); image_box->image(shared); // show the scaled image image_size->copy_label(title); value(image_box->parent()); -- cgit v1.2.3