mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Add resize_image script function
This commit is contained in:
@@ -304,6 +304,19 @@ bool EnlargeImage::operator == (const GeneratedImage& that) const {
|
||||
&& border_size == that2->border_size;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ResizeImage
|
||||
|
||||
Image ResizeImage::generate(const Options& opt) const {
|
||||
Image img = image->generate(opt);
|
||||
return resample(img, width, height);
|
||||
}
|
||||
bool ResizeImage::operator == (const GeneratedImage& that) const {
|
||||
const ResizeImage* that2 = dynamic_cast<const ResizeImage*>(&that);
|
||||
return that2 && *image == *that2->image
|
||||
&& width == that2->width
|
||||
&& height == that2->height;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : CropImage
|
||||
|
||||
Image CropImage::generate(const Options& opt) const {
|
||||
|
||||
@@ -287,6 +287,21 @@ private:
|
||||
double border_size;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : ResizeImage
|
||||
|
||||
/// Resize an image by resampling it
|
||||
class ResizeImage : public SimpleFilterImage {
|
||||
public:
|
||||
inline ResizeImage(const GeneratedImageP& image, int width, int height)
|
||||
: SimpleFilterImage(image), width(max(1, width)), height(max(1, height))
|
||||
{}
|
||||
Image generate(const Options& opt) const override;
|
||||
bool operator == (const GeneratedImage& that) const override;
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : CropImage
|
||||
|
||||
/// Crop an image at a certain point, to a certain size
|
||||
|
||||
Reference in New Issue
Block a user