mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Added icon for MSE in packages window;
Added resample(image,width,height), instead of always passing in images git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@806 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -31,24 +31,18 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) {
|
||||
if ((iw == options.width && ih == options.height) || (options.width == 0 && options.height == 0)) {
|
||||
// zoom?
|
||||
if (options.zoom != 1.0) {
|
||||
Image resampled_image(iw * options.zoom, ih * options.zoom, false);
|
||||
resample(image, resampled_image);
|
||||
image = resampled_image;
|
||||
image = resample(image, iw * options.zoom, ih * options.zoom);
|
||||
} else {
|
||||
// already the right size
|
||||
}
|
||||
} else if (options.height == 0) {
|
||||
// width is given, determine height
|
||||
int h = options.width * ih / iw;
|
||||
Image resampled_image(options.width, h, false);
|
||||
resample(image, resampled_image);
|
||||
image = resampled_image;
|
||||
image = resample(image, options.width, h);
|
||||
} else if (options.width == 0) {
|
||||
// height is given, determine width
|
||||
int w = options.height * iw / ih;
|
||||
Image resampled_image(w, options.height, false);
|
||||
resample(image, resampled_image);
|
||||
image = resampled_image;
|
||||
image = resample(image, w, options.height);
|
||||
} else if (options.preserve_aspect == ASPECT_FIT) {
|
||||
// determine actual size of resulting image
|
||||
int w, h;
|
||||
@@ -59,18 +53,14 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) {
|
||||
w = options.height * iw / ih;
|
||||
h = options.height;
|
||||
}
|
||||
Image resampled_image(w, h, false);
|
||||
resample(image, resampled_image);
|
||||
image = resampled_image;
|
||||
image = resample(image, w, h);
|
||||
} else {
|
||||
Image resampled_image(options.width, options.height, false);
|
||||
if (options.preserve_aspect == ASPECT_BORDER && (options.width < options.height * 3) && (options.height < options.width * 3)) {
|
||||
// preserve the aspect ratio if there is not too much difference
|
||||
resample_preserve_aspect(image, resampled_image);
|
||||
image = resample_preserve_aspect(image, options.width, options.height);
|
||||
} else {
|
||||
resample(image, resampled_image);
|
||||
image = resample(image, options.width, options.height);
|
||||
}
|
||||
image = resampled_image;
|
||||
}
|
||||
// saturate?
|
||||
if (options.saturate) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
/// Resample (resize) an image, uses bilenear filtering
|
||||
void resample(const Image& img_in, Image& img_out);
|
||||
Image resample(const Image& img_in, int width, int height);
|
||||
|
||||
/// Resamples an image, first clips the input image to a specified rectangle
|
||||
/** The selected rectangle is resampled into the entire output image */
|
||||
@@ -35,6 +36,7 @@ enum PreserveAspect
|
||||
|
||||
/// Resample an image, but preserve the aspect ratio by adding a transparent border around the output if needed.
|
||||
void resample_preserve_aspect(const Image& img_in, Image& img_out);
|
||||
Image resample_preserve_aspect(const Image& img_in, int width, int height);
|
||||
|
||||
/// Resample an image to create a sharp result by applying a sharpening filter
|
||||
/** Amount must be between 0 and 100 */
|
||||
|
||||
@@ -125,6 +125,15 @@ void resample_pass(const Image& img_in, Image& img_out, int offset_in, int offse
|
||||
void resample(const Image& img_in, Image& img_out) {
|
||||
resample_and_clip(img_in, img_out, wxRect(0, 0, img_in.GetWidth(), img_in.GetHeight()));
|
||||
}
|
||||
Image resample(const Image& img_in, int width, int height) {
|
||||
if (img_in.GetWidth() == width && img_in.GetHeight() == height) {
|
||||
return img_in; // already the right size
|
||||
} else {
|
||||
Image img_out(width,height,false);
|
||||
resample(img_in, img_out);
|
||||
return img_out;
|
||||
}
|
||||
}
|
||||
|
||||
void resample_and_clip(const Image& img_in, Image& img_out, wxRect rect) {
|
||||
// mask to alpha
|
||||
@@ -171,6 +180,16 @@ void resample_preserve_aspect(const Image& img_in, Image& img_out) {
|
||||
resample_pass(img_temp, img_out, 0, offset_out, img_in.GetHeight(), img_temp.GetWidth(), rheight, img_out.GetWidth(), rwidth, 1, 1);
|
||||
}
|
||||
|
||||
Image resample_preserve_aspect(const Image& img_in, int width, int height) {
|
||||
if (img_in.GetWidth() == width && img_in.GetHeight() == height) {
|
||||
return img_in; // already the right size
|
||||
} else {
|
||||
Image img_out(width,height,false);
|
||||
resample_preserve_aspect(img_in, img_out);
|
||||
return img_out;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Sharpening
|
||||
|
||||
void sharp_downsample(const Image& img_in, Image& img_out, int amount);
|
||||
|
||||
Reference in New Issue
Block a user