mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Small changes to resize
This commit is contained in:
parent
c9116cc3db
commit
2fac39d779
4 changed files with 20 additions and 15 deletions
|
@ -167,14 +167,4 @@ public enum HotkeyStatus
|
||||||
Failed,
|
Failed,
|
||||||
NotConfigured
|
NotConfigured
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ResizeMode
|
|
||||||
{
|
|
||||||
[Description("Resizes all images to the specified size.")]
|
|
||||||
ResizeAll,
|
|
||||||
[Description("Only resize image if it is bigger than specified size.")]
|
|
||||||
ResizeIfBigger,
|
|
||||||
[Description("Only resize image if it is smaller than specified size.")]
|
|
||||||
ResizeIfSmaller
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -23,6 +23,8 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ShareX.ImageEffectsLib
|
namespace ShareX.ImageEffectsLib
|
||||||
{
|
{
|
||||||
public enum WatermarkType
|
public enum WatermarkType
|
||||||
|
@ -30,4 +32,14 @@ public enum WatermarkType
|
||||||
Text,
|
Text,
|
||||||
Image
|
Image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ResizeMode
|
||||||
|
{
|
||||||
|
[Description("Resizes all images to the specified size.")]
|
||||||
|
ResizeAll,
|
||||||
|
[Description("Only resize image if it is bigger than specified size.")]
|
||||||
|
ResizeIfBigger,
|
||||||
|
[Description("Only resize image if it is smaller than specified size.")]
|
||||||
|
ResizeIfSmaller
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -52,8 +52,11 @@ public override Image Apply(Image img)
|
||||||
int width = Width <= 0 ? (int)((float)Height / img.Height * img.Width) : Width;
|
int width = Width <= 0 ? (int)((float)Height / img.Height * img.Width) : Width;
|
||||||
int height = Height <= 0 ? (int)((float)Width / img.Width * img.Height) : Height;
|
int height = Height <= 0 ? (int)((float)Width / img.Width * img.Height) : Height;
|
||||||
|
|
||||||
if (Mode == ResizeMode.ResizeIfBigger && img.Width <= width && img.Height <= height) return img;
|
if ((Mode == ResizeMode.ResizeIfBigger && img.Width <= width && img.Height <= height) ||
|
||||||
if (Mode == ResizeMode.ResizeIfSmaller && img.Width >= width && img.Height >= height) return img;
|
(Mode == ResizeMode.ResizeIfSmaller && img.Width >= width && img.Height >= height))
|
||||||
|
{
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
return ImageHelpers.ResizeImage(img, width, height);
|
return ImageHelpers.ResizeImage(img, width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
Copyright (c) 2007-2016 ShareX Team
|
Copyright (c) 2007-2017 ShareX Team
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
|
Loading…
Reference in a new issue