2017-05-07 08:53:46 +12:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2018-01-02 03:59:14 +13:00
|
|
|
|
Copyright (c) 2007-2018 ShareX Team
|
2017-05-07 08:53:46 +12:00
|
|
|
|
|
|
|
|
|
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 System.Drawing;
|
2017-05-24 10:53:57 +12:00
|
|
|
|
using System.Drawing.Drawing2D;
|
2017-05-07 08:53:46 +12:00
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
|
|
|
|
public class ImageScreenDrawingShape : BaseDrawingShape
|
|
|
|
|
{
|
|
|
|
|
public override ShapeType ShapeType { get; } = ShapeType.DrawingImageScreen;
|
|
|
|
|
|
|
|
|
|
public Image Image { get; private set; }
|
2018-01-06 18:30:04 +13:00
|
|
|
|
public ImageEditorInterpolationMode ImageInterpolationMode { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override void OnConfigLoad()
|
|
|
|
|
{
|
|
|
|
|
ImageInterpolationMode = AnnotationOptions.ImageInterpolationMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnConfigSave()
|
|
|
|
|
{
|
|
|
|
|
AnnotationOptions.ImageInterpolationMode = ImageInterpolationMode;
|
|
|
|
|
}
|
2017-05-07 08:53:46 +12:00
|
|
|
|
|
|
|
|
|
public override void OnDraw(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
if (Image == null)
|
|
|
|
|
{
|
2017-05-09 11:38:37 +12:00
|
|
|
|
if (IsValidShape)
|
|
|
|
|
{
|
2017-11-15 01:05:12 +13:00
|
|
|
|
Manager.DrawRegionArea(g, RectangleInsideCanvas, true);
|
2017-05-09 11:38:37 +12:00
|
|
|
|
}
|
2017-05-07 08:53:46 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawImage(g);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void DrawImage(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
if (Image != null)
|
|
|
|
|
{
|
2018-01-06 18:37:18 +13:00
|
|
|
|
g.PixelOffsetMode = PixelOffsetMode.Half;
|
2018-01-06 18:30:04 +13:00
|
|
|
|
g.InterpolationMode = Manager.GetInterpolationMode(ImageInterpolationMode);
|
2018-01-06 18:37:18 +13:00
|
|
|
|
|
2017-05-07 08:53:46 +12:00
|
|
|
|
g.DrawImage(Image, Rectangle);
|
2018-01-06 18:37:18 +13:00
|
|
|
|
|
|
|
|
|
g.PixelOffsetMode = PixelOffsetMode.Default;
|
2017-05-24 10:53:57 +12:00
|
|
|
|
g.InterpolationMode = InterpolationMode.Bilinear;
|
2017-05-07 08:53:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnCreated()
|
|
|
|
|
{
|
2017-05-09 11:38:37 +12:00
|
|
|
|
if (IsValidShape)
|
|
|
|
|
{
|
2017-11-15 01:05:12 +13:00
|
|
|
|
Rectangle = RectangleInsideCanvas;
|
2017-05-09 11:38:37 +12:00
|
|
|
|
Image = Manager.CropImage(Rectangle);
|
|
|
|
|
}
|
2017-05-07 08:53:46 +12:00
|
|
|
|
|
|
|
|
|
if (Image == null)
|
|
|
|
|
{
|
|
|
|
|
Remove();
|
|
|
|
|
}
|
2017-11-21 07:25:18 +13:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base.OnCreated();
|
|
|
|
|
}
|
2017-05-07 08:53:46 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (Image != null)
|
|
|
|
|
{
|
|
|
|
|
Image.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|