mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
restore ability to paste in Paint
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user