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.
This commit is contained in:
parent
af5fb2aeb3
commit
3679dd5fbd
@ -23,6 +23,7 @@
|
|||||||
#include <FL/platform.H>
|
#include <FL/platform.H>
|
||||||
#include "Fl_GDI_Graphics_Driver.H"
|
#include "Fl_GDI_Graphics_Driver.H"
|
||||||
#include "../WinAPI/Fl_WinAPI_Screen_Driver.H"
|
#include "../WinAPI/Fl_WinAPI_Screen_Driver.H"
|
||||||
|
#include <FL/Fl_Image_Surface.H>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class Fl_GDI_Copy_Surface_Driver : public Fl_Copy_Surface_Driver {
|
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 ( hmf != NULL ) {
|
||||||
if ( OpenClipboard (NULL) ){
|
if ( OpenClipboard (NULL) ){
|
||||||
EmptyClipboard ();
|
EmptyClipboard ();
|
||||||
|
// put first the vectorial form of the graphics in the clipboard
|
||||||
SetClipboardData (CF_ENHMETAFILE, hmf);
|
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 ();
|
CloseClipboard ();
|
||||||
}
|
}
|
||||||
DeleteEnhMetaFile(hmf);
|
DeleteEnhMetaFile(hmf);
|
||||||
|
Loading…
Reference in New Issue
Block a user