From 5dd2b4409f50b577b4288c5e5a90fadfff7f15d1 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 19 Jul 2019 08:09:22 +0200 Subject: [PATCH] Windows: add bitmap version of graphics when copying to clipboard --- src/Fl_Copy_Surface.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Fl_Copy_Surface.cxx b/src/Fl_Copy_Surface.cxx index 5cab56609..909c5e73f 100644 --- a/src/Fl_Copy_Surface.cxx +++ b/src/Fl_Copy_Surface.cxx @@ -128,7 +128,18 @@ Fl_Copy_Surface::~Fl_Copy_Surface() if ( hmf != NULL ) { if ( OpenClipboard (NULL) ){ EmptyClipboard (); + // first, put vectorial version of graphics in the clipboard SetClipboardData (CF_ENHMETAFILE, hmf); + // next, put BITMAP version of the graphics in the clipboard + RECT rect = {0, 0, width, height}; + Fl_Offscreen of = CreateCompatibleBitmap(fl_GetDC(0), width, height); + fl_begin_offscreen(of); + fl_color(FL_WHITE); // draw white background + fl_rectf(0, 0, width, height); + PlayEnhMetaFile((HDC)fl_gc, hmf, &rect); // draw metafile to offscreen buffer + fl_end_offscreen(); + SetClipboardData(CF_BITMAP, (HBITMAP)of); + fl_delete_offscreen(of); CloseClipboard (); } DeleteEnhMetaFile(hmf);