diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-07-18 17:11:03 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-07-18 17:11:03 +0200 |
| commit | 3679dd5fbdeed711804ebb9eb52abc335440b903 (patch) | |
| tree | fee6ce8ef549a98fbcbd8812c04205acaf94fca0 /src | |
| parent | af5fb2aeb33a55b78d92d16be53d790ee199a848 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
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 <FL/platform.H> #include "Fl_GDI_Graphics_Driver.H" #include "../WinAPI/Fl_WinAPI_Screen_Driver.H" +#include <FL/Fl_Image_Surface.H> #include <windows.h> 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); |
