mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
rename script functions
This commit is contained in:
@@ -433,6 +433,11 @@ Image BleedEdgedImage::generate(const Options& opt) {
|
||||
pixels[3 * pixel + 2] = pixels[3 * mirror + 2];
|
||||
alpha[pixel] = alpha[mirror];
|
||||
}
|
||||
}
|
||||
// transfer metadata
|
||||
if (base_img.HasOption(wxIMAGE_OPTION_PNG_DESCRIPTION)) {
|
||||
String desc = transformAllEncodedRects(base_img.GetOption(wxIMAGE_OPTION_PNG_DESCRIPTION), 1.0, 0.0, dw, dh, width, height);
|
||||
img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, desc);
|
||||
}
|
||||
// done
|
||||
return img;
|
||||
@@ -460,13 +465,17 @@ Image InsertedImage::generate(const Options& opt) {
|
||||
Image img = wxImage(width, height, false);
|
||||
img.InitAlpha();
|
||||
Byte* data = img.GetData();
|
||||
Byte* alpha = img.GetAlpha();
|
||||
Byte* alpha = img.GetAlpha();
|
||||
Byte r = background_color.Red();
|
||||
Byte g = background_color.Green();
|
||||
Byte b = background_color.Blue();
|
||||
Byte a = background_color.Alpha();
|
||||
for (UInt i = 0; i < size; ++i) {
|
||||
data[0] = background_color.Red();
|
||||
data[1] = background_color.Green();
|
||||
data[2] = background_color.Blue();
|
||||
data[0] = r;
|
||||
data[1] = g;
|
||||
data[2] = b;
|
||||
data += 3;
|
||||
alpha[0] = background_color.Alpha();
|
||||
alpha[0] = a;
|
||||
alpha += 1;
|
||||
}
|
||||
img.Paste(base_img, base_x, base_y, wxIMAGE_ALPHA_BLEND_COMPOSE);
|
||||
@@ -488,13 +497,33 @@ bool InsertedImage::operator == (const GeneratedImage& that) const {
|
||||
// ----------------------------------------------------------------------------- : CropImage
|
||||
|
||||
Image CropImage::generate(const Options& opt) {
|
||||
return image->generate(opt).Size(wxSize((int)width, (int)height), wxPoint(-(int)offset_x, -(int)offset_y));
|
||||
UInt size = width * height;
|
||||
Image img = wxImage(width, height, false);
|
||||
img.InitAlpha();
|
||||
Byte* data = img.GetData();
|
||||
Byte* alpha = img.GetAlpha();
|
||||
Byte r = background_color.Red();
|
||||
Byte g = background_color.Green();
|
||||
Byte b = background_color.Blue();
|
||||
Byte a = background_color.Alpha();
|
||||
for (UInt i = 0; i < size; ++i) {
|
||||
data[0] = r;
|
||||
data[1] = g;
|
||||
data[2] = b;
|
||||
data += 3;
|
||||
alpha[0] = a;
|
||||
alpha += 1;
|
||||
}
|
||||
Image base_img = image->generate(opt);
|
||||
img.Paste(base_img, -(int)offset_x, -(int)offset_y, wxIMAGE_ALPHA_BLEND_OVER);
|
||||
return img;
|
||||
}
|
||||
bool CropImage::operator == (const GeneratedImage& that) const {
|
||||
const CropImage* that2 = dynamic_cast<const CropImage*>(&that);
|
||||
return that2 && *image == *that2->image
|
||||
&& width == that2->width && height == that2->height
|
||||
&& offset_x == that2->offset_x && offset_y == that2->offset_y;
|
||||
&& offset_x == that2->offset_x && offset_y == that2->offset_y
|
||||
&& background_color == that2->background_color;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : DropShadowImage
|
||||
|
||||
@@ -308,14 +308,15 @@ private:
|
||||
/// Crop an image at a certain point, to a certain size
|
||||
class CropImage : public SimpleFilterImage {
|
||||
public:
|
||||
inline CropImage(const GeneratedImageP& image, double width, double height, double offset_x, double offset_y)
|
||||
: SimpleFilterImage(image), width(width), height(height), offset_x(offset_x), offset_y(offset_y)
|
||||
inline CropImage(const GeneratedImageP& image, double width, double height, double offset_x, double offset_y, Color background_color)
|
||||
: SimpleFilterImage(image), width(width), height(height), offset_x(offset_x), offset_y(offset_y), background_color(background_color)
|
||||
{}
|
||||
Image generate(const Options& opt) override;
|
||||
bool operator == (const GeneratedImage& that) const override;
|
||||
private:
|
||||
double width, height;
|
||||
double offset_x, offset_y;
|
||||
Color background_color;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : StrokeImage
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <data/format/image_encoding.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Implementation
|
||||
|
||||
@@ -38,6 +39,14 @@ Image rotate_image_impl(const Image& img) {
|
||||
in += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// transfer metadata
|
||||
if (img.HasOption(wxIMAGE_OPTION_PNG_DESCRIPTION)) {
|
||||
if (!almost_equal(Rotater::angle(), rad180)) {
|
||||
swap(width, height);
|
||||
}
|
||||
String desc = transformAllEncodedRects(img.GetOption(wxIMAGE_OPTION_PNG_DESCRIPTION), 1.0, Rotater::angle(), 0, 0, width, height);
|
||||
ret.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, desc);
|
||||
}
|
||||
// ret is rotated image
|
||||
return ret;
|
||||
@@ -56,7 +65,8 @@ struct Rotate90deg {
|
||||
int mx = y;
|
||||
int my = w - x - 1;
|
||||
return h * my + mx; // note: h, since that is the width of the target image
|
||||
}
|
||||
}
|
||||
inline static Radians angle() { return rad90; }
|
||||
};
|
||||
|
||||
struct Rotate180deg {
|
||||
@@ -67,7 +77,8 @@ struct Rotate180deg {
|
||||
UInt mx = w - x - 1;
|
||||
UInt my = h - y - 1;
|
||||
return w * my + mx;
|
||||
}
|
||||
}
|
||||
inline static Radians angle() { return rad180; }
|
||||
};
|
||||
|
||||
struct Rotate270deg {
|
||||
@@ -78,7 +89,8 @@ struct Rotate270deg {
|
||||
UInt mx = h - y - 1;
|
||||
UInt my = x;
|
||||
return h * my + mx;
|
||||
}
|
||||
}
|
||||
inline static Radians angle() { return rad270; }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Interface
|
||||
|
||||
Reference in New Issue
Block a user