Skip to content

Commit

Permalink
Provide original PNG as wxCustomDataObject (#297)
Browse files Browse the repository at this point in the history
When available, use the original PNG data instead of the bitmap
for the clipboard.
  • Loading branch information
tobiolo authored Dec 7, 2022
1 parent 44ebd49 commit c0f5046
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,13 @@ struct Document {
if (selected.Thin()) return NoThin();

if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxBitmapDataObject(c->text.image->bm_orig));
if (!c->text.image->png_data.empty()) {
wxCustomDataObject* pngimage = new wxCustomDataObject(wxDF_BITMAP);
pngimage->SetData(c->text.image->png_data.size(), c->text.image->png_data.data());
wxTheClipboard->SetData(pngimage);
} else {
wxTheClipboard->SetData(new wxBitmapDataObject(c->text.image->bm_orig));
}
wxTheClipboard->Close();
}
return _(L"Image copied to clipboard");
Expand Down

0 comments on commit c0f5046

Please sign in to comment.