From 3679dd5fbdeed711804ebb9eb52abc335440b903 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 18 Jul 2019 17:11:03 +0200 Subject: Fl_GDI_Copy_Surface_Driver: add BITMAP version of graphics to clipboard When copying graphical data to the clipboard with Fl_Copy_Surface, both a vectorial and a bitmap versions of the graphics are copied. --- src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx index 5041cc7e4..7a8f24c6c 100644 --- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx @@ -23,6 +23,7 @@ #include #include "Fl_GDI_Graphics_Driver.H" #include "../WinAPI/Fl_WinAPI_Screen_Driver.H" +#include #include class Fl_GDI_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { @@ -74,7 +75,21 @@ Fl_GDI_Copy_Surface_Driver::~Fl_GDI_Copy_Surface_Driver() { if ( hmf != NULL ) { if ( OpenClipboard (NULL) ){ EmptyClipboard (); + // put first the vectorial form of the graphics in the clipboard SetClipboardData (CF_ENHMETAFILE, hmf); + // then put a BITMAP version of the graphics in the clipboard + float scaling = driver()->scale(); + int W = width * scaling, H = height * scaling; + RECT rect = {0, 0, W, H}; + Fl_Image_Surface *surf = new Fl_Image_Surface(W, H); + Fl_Surface_Device::push_current(surf); + fl_color(FL_WHITE); // draw white background + fl_rectf(0, 0, W, H); + PlayEnhMetaFile((HDC)surf->driver()->gc(), hmf, &rect); // draw metafile to offscreen buffer + SetClipboardData(CF_BITMAP, surf->offscreen()); + Fl_Surface_Device::pop_current(); + delete surf; + CloseClipboard (); } DeleteEnhMetaFile(hmf); -- cgit v1.2.3