restore ability to paste in Paint

This commit is contained in:
GenevensiS
2026-05-10 09:39:19 +02:00
parent 50b649beca
commit 19b144f37b
8 changed files with 37 additions and 19 deletions
+14 -8
View File
@@ -161,23 +161,29 @@ KeywordP KeywordDataObject::getKeyword(const SetP& set) {
// ----------------------------------------------------------------------------- : Card on clipboard
CardsOnClipboard::CardsOnClipboard(const SetP& set, const String id, const vector<CardP>& cards) {
wxBusyCursor busy;
// Conversion to image file
if (cards.size() < 6) {
Bitmap bmp;
Image img;
if (cards.size() == 1) {
img = export_image(set, cards[0]);
img = export_image(set, cards[0], true, 1.0, 0.0, 0.0, &bmp);
}
else {
img = export_image(set, cards);
img = export_image(set, cards);
bmp = Bitmap(img);
}
String temp_path = wxFileName::CreateTempFileName(_("mse")) + _(".png");
img.SaveFile(temp_path, wxBITMAP_TYPE_PNG);
wxFileDataObject* fileData = new wxFileDataObject();
fileData->AddFile(temp_path);
Add(fileData);
wxImageDataObject* imgData = new wxImageDataObject();
//wxFileDataObject* fileData = new wxFileDataObject(); // needed for pasting on desktop, but slow
//String temp_path = wxFileName::CreateTempFileName(_("mse")) + _(".png");
//img.SaveFile(temp_path, wxBITMAP_TYPE_PNG);
//fileData->AddFile(temp_path);
//Add(fileData);
wxImageDataObject* imgData = new wxImageDataObject(); // needed for metadata
imgData->SetImage(img);
Add(imgData);
wxBitmapDataObject* bmpData = new wxBitmapDataObject(); // needed for pasting in MSPaint
bmpData->SetBitmap(bmp);
Add(bmpData);
}
// Conversion to serialized card format
Add(new CardsDataObject(set, id, cards), true);
+1 -1
View File
@@ -89,7 +89,7 @@ FileFormatP mtg_editor_file_format();
// ----------------------------------------------------------------------------- : Other ways to export
/// Generate a wxImage of one or more cards
Image export_image(const SetP& set, const CardP& card, bool write_metadata = true, double zoom = 1.0, Radians angle_radians = 0.0, double bleed_pixels = 0.0);
Image export_image(const SetP& set, const CardP& card, bool write_metadata = true, double zoom = 1.0, Radians angle_radians = 0.0, double bleed_pixels = 0.0, Bitmap* out_bitmap = nullptr);
Image export_image(const SetP& set, const vector<CardP>& cards, int padding = 2, double global_zoom = 1.0, bool use_zoom_setting = true, bool use_rotation_setting = true, bool use_bleed_setting = false);
/// Export the image of one or more cards to a given filename, using the app's zoom, rotation and bleed settings, and including metadata
+5 -3
View File
@@ -35,7 +35,7 @@ Rotation ZoomedUnrotatedDataViewer::getRotation() const {
// ----------------------------------------------------------------------------- : wxImage export
Image export_image(const SetP& set, const CardP& card, bool write_metadata, double zoom, Radians angle_radians, double bleed_pixels) {
Image export_image(const SetP& set, const CardP& card, bool write_metadata, double zoom, Radians angle_radians, double bleed_pixels, Bitmap* out_bitmap) {
if (!set) throw Error(_("no set"));
/// create and zoom
ZoomedUnrotatedDataViewer viewer = ZoomedUnrotatedDataViewer(zoom);
@@ -51,6 +51,9 @@ Image export_image(const SetP& set, const CardP& card, bool write_metadata, doub
viewer.draw(dc);
dc.SelectObject(wxNullBitmap);
Image img = bitmap.ConvertToImage();
/// return bitmap if needed
if (out_bitmap) *out_bitmap = std::move(bitmap);
/// rotate
img = rotate_image(img, angle_radians);
@@ -218,8 +221,7 @@ void export_image(const SetP& set, const CardP& card, const String& filename) {
img.SaveFile(filename);
}
void export_image(const SetP& set, const vector<CardP>& cards, const String& path, const String& filename_template, FilenameConflicts conflicts)
{
void export_image(const SetP& set, const vector<CardP>& cards, const String& path, const String& filename_template, FilenameConflicts conflicts) {
wxBusyCursor busy;
// Script
ScriptP filename_script = parse(filename_template, nullptr, true);