mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
add bleed edge option, get_card_export_settings function
This commit is contained in:
+12
-19
@@ -50,31 +50,24 @@ bool ImageValueEditor::onLeftDClick(const RealPoint&, wxMouseEvent&) {
|
||||
|
||||
void ImageValueEditor::sliceImage(const Image& image, const String& filename, const String& cardname) {
|
||||
if (!image.Ok()) return;
|
||||
// determine import scale based on the user's settings.
|
||||
double import_scale = 1.0;
|
||||
StyleSheetP stylesheet = editor().getCard()->stylesheet;
|
||||
if (!stylesheet) stylesheet = editor().getSet()->stylesheet;
|
||||
if (stylesheet) import_scale = settings.importScaleSettingsFor(*stylesheet);
|
||||
RealSize target_size = RealSize(style().getSize() * import_scale);
|
||||
target_size = RealSize((int)target_size.width, (int)target_size.height);
|
||||
// mask
|
||||
GeneratedImage::Options options((int)style().width, (int)style().height, &parent.getStylePackage(), &parent.getLocalPackage());
|
||||
GeneratedImage::Options options((int)target_size.width, (int)target_size.height, &parent.getStylePackage(), &parent.getLocalPackage());
|
||||
AlphaMask mask;
|
||||
style().mask.getNoCache(options,mask);
|
||||
// slice
|
||||
ImageSliceWindow s(wxGetTopLevelParent(&editor()), image, filename, cardname, style().getSize(), mask);
|
||||
style().mask.getNoCache(options, mask);
|
||||
// slice
|
||||
ImageSliceWindow s(wxGetTopLevelParent(&editor()), image, filename, cardname, target_size, mask);
|
||||
// clicked ok?
|
||||
if (s.ShowModal() == wxID_OK) {
|
||||
// store the image into the set
|
||||
LocalFileName new_image_file = getLocalPackage().newFileName(field().name, settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package
|
||||
|
||||
// Specify a desired size based on the stylesheet and a scale multiplier defined within the user's settings.
|
||||
// Storing at a greater than 100% resolution allows for better exports >100%, but may change how images look when filters (sharpen) are applied.
|
||||
// It also disrupts some of the patterns in use for doing popout planeswalkers since you have to do the math at both scales.
|
||||
// Additionally, this bloats the set file size as even under-resolution images are upscaled to the new minimum size.
|
||||
double internal_scale = 1.0;
|
||||
try {
|
||||
// surrounding this in try catch to be safe for now. maybe this is overkill
|
||||
StyleSheetP stylesheet = editor().getCard()->stylesheet;
|
||||
if (!stylesheet) stylesheet = editor().getSet()->stylesheet;
|
||||
internal_scale = settings.internalScaleSettingsFor(*stylesheet);
|
||||
} catch (...) {
|
||||
queue_message(MESSAGE_ERROR, _("Could not find stylesheet to determine export zoom.\nfilename: " + filename + _("\ncardname: " + cardname)));
|
||||
}
|
||||
Image img = s.getImage(internal_scale);
|
||||
Image img = s.getImage();
|
||||
img.SaveFile(getLocalPackage().nameOut(new_image_file), wxBITMAP_TYPE_PNG); // always use PNG images, see #69. Disk space is cheap anyway.
|
||||
addAction(value_action(valueP(), new_image_file));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user