mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added auto crop image effect
This commit is contained in:
parent
1f4bf6f1c0
commit
f2f62e7ffd
5 changed files with 61 additions and 23 deletions
|
@ -1782,10 +1782,6 @@ public static Rectangle FindAutoCropRectangle(Bitmap bmp, bool sameColorCrop = f
|
||||||
return crop;
|
return crop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If crop rectangle and source image rectangle is same then null will be returned.
|
|
||||||
/// After auto crop, source image will be disposed.
|
|
||||||
/// </summary>
|
|
||||||
public static Bitmap AutoCropImage(Bitmap bmp, bool sameColorCrop = false)
|
public static Bitmap AutoCropImage(Bitmap bmp, bool sameColorCrop = false)
|
||||||
{
|
{
|
||||||
Rectangle source = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
Rectangle source = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
||||||
|
@ -1802,7 +1798,7 @@ public static Bitmap AutoCropImage(Bitmap bmp, bool sameColorCrop = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RotateFlipType RotateImageByExifOrientationData(Image img, bool removeExifOrientationData = true)
|
public static RotateFlipType RotateImageByExifOrientationData(Image img, bool removeExifOrientationData = true)
|
||||||
|
|
|
@ -82,6 +82,7 @@ private void AddAllEffectsToContextMenu()
|
||||||
typeof(DrawText));
|
typeof(DrawText));
|
||||||
|
|
||||||
AddEffectToContextMenu(Resources.ImageEffectsForm_AddAllEffectsToTreeView_Manipulations,
|
AddEffectToContextMenu(Resources.ImageEffectsForm_AddAllEffectsToTreeView_Manipulations,
|
||||||
|
typeof(AutoCrop),
|
||||||
typeof(Canvas),
|
typeof(Canvas),
|
||||||
typeof(Crop),
|
typeof(Crop),
|
||||||
typeof(Flip),
|
typeof(Flip),
|
||||||
|
|
|
@ -171,9 +171,6 @@
|
||||||
<data name="lvEffects.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
<data name="lvEffects.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||||
<value>Top, Bottom, Left</value>
|
<value>Top, Bottom, Left</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="chEffect.Width" type="System.Int32, mscorlib">
|
|
||||||
<value>164</value>
|
|
||||||
</data>
|
|
||||||
<data name="lvEffects.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="lvEffects.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>8, 72</value>
|
<value>8, 72</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -195,6 +192,9 @@
|
||||||
<data name=">>lvEffects.ZOrder" xml:space="preserve">
|
<data name=">>lvEffects.ZOrder" xml:space="preserve">
|
||||||
<value>18</value>
|
<value>18</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="chEffect.Width" type="System.Int32, mscorlib">
|
||||||
|
<value>164</value>
|
||||||
|
</data>
|
||||||
<data name="btnRemove.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btnRemove.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>120, 40</value>
|
<value>120, 40</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -369,18 +369,6 @@
|
||||||
<metadata name="cmsLoadImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="cmsLoadImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>126, 17</value>
|
<value>126, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="tsmiLoadImageFromFile.Size" type="System.Drawing.Size, System.Drawing">
|
|
||||||
<value>130, 22</value>
|
|
||||||
</data>
|
|
||||||
<data name="tsmiLoadImageFromFile.Text" xml:space="preserve">
|
|
||||||
<value>From file...</value>
|
|
||||||
</data>
|
|
||||||
<data name="tsmiLoadImageFromClipboard.Size" type="System.Drawing.Size, System.Drawing">
|
|
||||||
<value>130, 22</value>
|
|
||||||
</data>
|
|
||||||
<data name="tsmiLoadImageFromClipboard.Text" xml:space="preserve">
|
|
||||||
<value>From clipboard</value>
|
|
||||||
</data>
|
|
||||||
<data name="cmsLoadImage.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="cmsLoadImage.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>131, 48</value>
|
<value>131, 48</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -414,6 +402,18 @@
|
||||||
<data name=">>mbLoadImage.ZOrder" xml:space="preserve">
|
<data name=">>mbLoadImage.ZOrder" xml:space="preserve">
|
||||||
<value>9</value>
|
<value>9</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="tsmiLoadImageFromFile.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>130, 22</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsmiLoadImageFromFile.Text" xml:space="preserve">
|
||||||
|
<value>From file...</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsmiLoadImageFromClipboard.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>130, 22</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsmiLoadImageFromClipboard.Text" xml:space="preserve">
|
||||||
|
<value>From clipboard</value>
|
||||||
|
</data>
|
||||||
<data name="btnAddPreset.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btnAddPreset.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>8, 8</value>
|
<value>8, 8</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -463,7 +463,7 @@
|
||||||
<value>7</value>
|
<value>7</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cbPresets.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="cbPresets.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>296, 8</value>
|
<value>296, 9</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cbPresets.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="cbPresets.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>304, 21</value>
|
<value>304, 21</value>
|
||||||
|
@ -487,7 +487,7 @@
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="lblPresetName.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="lblPresetName.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>608, 12</value>
|
<value>608, 13</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="lblPresetName.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="lblPresetName.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>38, 13</value>
|
<value>38, 13</value>
|
||||||
|
@ -514,7 +514,7 @@
|
||||||
<value>Top, Left, Right</value>
|
<value>Top, Left, Right</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="txtPresetName.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="txtPresetName.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>672, 8</value>
|
<value>672, 9</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="txtPresetName.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="txtPresetName.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>288, 20</value>
|
<value>288, 20</value>
|
||||||
|
|
40
ShareX.ImageEffectsLib/Manipulations/AutoCrop.cs
Normal file
40
ShareX.ImageEffectsLib/Manipulations/AutoCrop.cs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (c) 2007-2018 ShareX Team
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using ShareX.HelpersLib;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace ShareX.ImageEffectsLib
|
||||||
|
{
|
||||||
|
[Description("Auto crop")]
|
||||||
|
internal class AutoCrop : ImageEffect
|
||||||
|
{
|
||||||
|
public override Image Apply(Image img)
|
||||||
|
{
|
||||||
|
return ImageHelpers.AutoCropImage((Bitmap)img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -128,6 +128,7 @@
|
||||||
<Compile Include="Adjustments\Inverse.cs" />
|
<Compile Include="Adjustments\Inverse.cs" />
|
||||||
<Compile Include="Adjustments\Saturation.cs" />
|
<Compile Include="Adjustments\Saturation.cs" />
|
||||||
<Compile Include="ImageEffectPreset.cs" />
|
<Compile Include="ImageEffectPreset.cs" />
|
||||||
|
<Compile Include="Manipulations\AutoCrop.cs" />
|
||||||
<Compile Include="Manipulations\Crop.cs" />
|
<Compile Include="Manipulations\Crop.cs" />
|
||||||
<Compile Include="Manipulations\RoundedCorners.cs" />
|
<Compile Include="Manipulations\RoundedCorners.cs" />
|
||||||
<Compile Include="Manipulations\Skew.cs" />
|
<Compile Include="Manipulations\Skew.cs" />
|
||||||
|
|
Loading…
Reference in a new issue