Slightly simplify examples/clipboard.cxx using Fl_Image::scale().

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12880 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2018-04-29 16:29:13 +00:00
parent 7dba27a404
commit 09f15fcac0

View File

@ -85,25 +85,21 @@ public:
int format = EnumClipboardFormats(0); int format = EnumClipboardFormats(0);
if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); } if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); }
while (format) { while (format) {
format = EnumClipboardFormats(format); format = EnumClipboardFormats(format);
if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); } if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); }
} }
HANDLE h; HANDLE h;
if ((h = GetClipboardData(CF_DIB))) { if ((h = GetClipboardData(CF_DIB))) {
LPBITMAPINFO lpBI = (LPBITMAPINFO)GlobalLock(h); LPBITMAPINFO lpBI = (LPBITMAPINFO)GlobalLock(h);
sprintf(p, " biBitCount=%d biCompression=%d biClrUsed=%d", sprintf(p, " biBitCount=%d biCompression=%d biClrUsed=%d",
lpBI->bmiHeader.biBitCount, (int)lpBI->bmiHeader.biCompression, (int)lpBI->bmiHeader.biClrUsed); lpBI->bmiHeader.biBitCount, (int)lpBI->bmiHeader.biCompression, (int)lpBI->bmiHeader.biClrUsed);
} }
CloseClipboard(); CloseClipboard();
#endif #endif
Fl_Shared_Image *oldim = (Fl_Shared_Image*)image_box->image(); Fl_Image *oldimg = image_box->image();
if (oldim) oldim->release(); delete oldimg;
float scale = fl_graphics_driver->scale(); im->scale(image_box->w(), image_box->h());
Fl_Shared_Image *shared = Fl_Shared_Image::get(im); image_box->image(im); // show the scaled image
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); image_size->copy_label(title);
value(image_box->parent()); value(image_box->parent());
window()->redraw(); window()->redraw();