mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Make sure image is valid size
This commit is contained in:
parent
32dd3cc77d
commit
9bcd554c43
1 changed files with 9 additions and 3 deletions
|
@ -28,6 +28,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -90,13 +91,13 @@ public override Image Apply(Image img)
|
|||
using (Graphics g = Graphics.FromImage(img))
|
||||
using (ImageFilesCache imageCache = new ImageFilesCache())
|
||||
{
|
||||
g.SetHighQuality();
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
for (int i = 0; i < ImageCount; i++)
|
||||
{
|
||||
string randomFile = MathHelpers.RandomPick(files);
|
||||
string file = MathHelpers.RandomPick(files);
|
||||
|
||||
Image img2 = imageCache.GetImage(randomFile);
|
||||
Image img2 = imageCache.GetImage(file);
|
||||
|
||||
if (img2 != null)
|
||||
{
|
||||
|
@ -126,6 +127,11 @@ private void DrawImage(Image img, Image img2, Graphics g)
|
|||
height = img2.Height;
|
||||
}
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle rect = new Rectangle(MathHelpers.Random(Math.Min(0, xOffset), Math.Max(0, xOffset)),
|
||||
MathHelpers.Random(Math.Min(0, yOffset), Math.Max(0, yOffset)), width, height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue