mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Merge pull request #15 from haganbmj/image_slice_fix_masks
fix: apply image scale after slice window to avoid mask issues
This commit is contained in:
@@ -34,7 +34,7 @@ private:
|
|||||||
|
|
||||||
Rotation UnzoomedDataViewer::getRotation() const {
|
Rotation UnzoomedDataViewer::getRotation() const {
|
||||||
if (!stylesheet) stylesheet = set->stylesheet;
|
if (!stylesheet) stylesheet = set->stylesheet;
|
||||||
int export_zoom = settings.stylesheetSettingsFor(set->stylesheetFor(card)).export_zoom();
|
double export_zoom = settings.stylesheetSettingsFor(set->stylesheetFor(card)).export_zoom();
|
||||||
bool use_viewer_rotation = !settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_normal_export();
|
bool use_viewer_rotation = !settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_normal_export();
|
||||||
|
|
||||||
if (use_viewer_rotation) {
|
if (use_viewer_rotation) {
|
||||||
|
|||||||
@@ -61,12 +61,13 @@ void ImageSlice::centerSelection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image ImageSlice::getSlice() const {
|
Image ImageSlice::getSlice(double scale) const {
|
||||||
if (selection.width == target_size.GetWidth() && selection.height == target_size.GetHeight() && selection.x == 0 && selection.y == 0) {
|
wxSize scaled_target_size = target_size * scale;
|
||||||
|
if (selection.width == scaled_target_size.GetWidth() && selection.height == scaled_target_size.GetHeight() && selection.x == 0 && selection.y == 0) {
|
||||||
// exactly the right size
|
// exactly the right size
|
||||||
return source.GetSubImage(selection);
|
return source.GetSubImage(selection);
|
||||||
}
|
}
|
||||||
Image target(target_size.GetWidth(), target_size.GetHeight(), false);
|
Image target(scaled_target_size.GetWidth(), scaled_target_size.GetHeight(), false);
|
||||||
if (sharpen && sharpen_amount > 0 && sharpen_amount <= 100) {
|
if (sharpen && sharpen_amount > 0 && sharpen_amount <= 100) {
|
||||||
sharp_resample_and_clip(source, target, selection, sharpen_amount);
|
sharp_resample_and_clip(source, target, selection, sharpen_amount);
|
||||||
} else {
|
} else {
|
||||||
@@ -195,8 +196,8 @@ void ImageSliceWindow::onOk(wxCommandEvent&) {
|
|||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image ImageSliceWindow::getImage() const {
|
Image ImageSliceWindow::getImage(double scale) const {
|
||||||
return slice.getSlice();
|
return slice.getSlice(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : ImageSliceWindow : Controls
|
// ----------------------------------------------------------------------------- : ImageSliceWindow : Controls
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
/// Attempt to center the current constraints
|
/// Attempt to center the current constraints
|
||||||
void centerSelection();
|
void centerSelection();
|
||||||
/// Get the sliced image
|
/// Get the sliced image
|
||||||
Image getSlice() const;
|
Image getSlice(double scale = 1.0) const;
|
||||||
|
|
||||||
// Zoom factor
|
// Zoom factor
|
||||||
inline double zoomX() const { return target_size.GetWidth() / (double)selection.width; }
|
inline double zoomX() const { return target_size.GetWidth() / (double)selection.width; }
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
ImageSliceWindow(Window* parent, const Image& source, const wxSize& target_size, const AlphaMask& target_mask);
|
ImageSliceWindow(Window* parent, const Image& source, const wxSize& target_size, const AlphaMask& target_mask);
|
||||||
|
|
||||||
/// Return the sliced image
|
/// Return the sliced image
|
||||||
Image getImage() const;
|
Image getImage(double scale) const;
|
||||||
|
|
||||||
// --------------------------------------------------- : Data
|
// --------------------------------------------------- : Data
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -41,16 +41,17 @@ void ImageValueEditor::sliceImage(const Image& image) {
|
|||||||
AlphaMask mask;
|
AlphaMask mask;
|
||||||
style().mask.getNoCache(options,mask);
|
style().mask.getNoCache(options,mask);
|
||||||
// slice
|
// slice
|
||||||
// Specify a desired size based on the stylesheet and a scale multiplier defined within the user's settings.
|
ImageSliceWindow s(wxGetTopLevelParent(&editor()), image, style().getSize(), mask);
|
||||||
// Storing at a greater than 100% resolution allows for better exports >100%, but may change how images look when filters (sharpen) are applied.
|
|
||||||
// Additionally, this bloats the set file size as even under-resolution images are upscaled to the new minimum size.
|
|
||||||
RealSize desired_slice_size = RealSize(style().getSize().width * settings.internal_scale, style().getSize().height * settings.internal_scale);
|
|
||||||
ImageSliceWindow s(wxGetTopLevelParent(&editor()), image, desired_slice_size, mask);
|
|
||||||
// clicked ok?
|
// clicked ok?
|
||||||
if (s.ShowModal() == wxID_OK) {
|
if (s.ShowModal() == wxID_OK) {
|
||||||
// store the image into the set
|
// 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
|
LocalFileName new_image_file = getLocalPackage().newFileName(field().name, settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package
|
||||||
Image img = s.getImage();
|
|
||||||
|
// 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.
|
||||||
|
Image img = s.getImage(settings.internal_scale);
|
||||||
img.SaveFile(getLocalPackage().nameOut(new_image_file), wxBITMAP_TYPE_PNG); // always use PNG images, see #69. Disk space is cheap anyway.
|
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));
|
addAction(value_action(valueP(), new_image_file));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user