2016-08-19 21:59: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
|
2016-08-19 21:59: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;
|
2016-08-19 21:59:46 +12:00
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
|
|
|
|
public class ImageDrawingShape : BaseDrawingShape
|
|
|
|
|
{
|
|
|
|
|
public override ShapeType ShapeType { get; } = ShapeType.DrawingImage;
|
|
|
|
|
|
2018-01-10 01:15:57 +13:00
|
|
|
|
public Image Image { get; protected set; }
|
2018-02-06 22:59:10 +13:00
|
|
|
|
public ImageEditorInterpolationMode ImageInterpolationMode { get; protected set; }
|
2018-01-06 18:30:04 +13:00
|
|
|
|
|
|
|
|
|
public override void OnConfigLoad()
|
|
|
|
|
{
|
|
|
|
|
ImageInterpolationMode = AnnotationOptions.ImageInterpolationMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnConfigSave()
|
|
|
|
|
{
|
|
|
|
|
AnnotationOptions.ImageInterpolationMode = ImageInterpolationMode;
|
|
|
|
|
}
|
2016-08-19 21:59:46 +12:00
|
|
|
|
|
2016-08-24 01:30:59 +12:00
|
|
|
|
public void SetImage(Image img, bool centerImage)
|
2016-08-19 21:59:46 +12:00
|
|
|
|
{
|
2016-08-19 22:22:12 +12:00
|
|
|
|
Dispose();
|
2016-08-19 21:59:46 +12:00
|
|
|
|
|
|
|
|
|
Image = img;
|
2016-08-20 01:16:40 +12:00
|
|
|
|
|
|
|
|
|
if (Image != null)
|
|
|
|
|
{
|
2016-08-24 01:30:59 +12:00
|
|
|
|
Point location;
|
|
|
|
|
Size size = Image.Size;
|
|
|
|
|
|
|
|
|
|
if (centerImage)
|
|
|
|
|
{
|
|
|
|
|
location = new Point(Rectangle.X - size.Width / 2, Rectangle.Y - size.Height / 2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
location = Rectangle.Location;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-16 19:36:21 +13:00
|
|
|
|
Rectangle = new Rectangle(location, size);
|
2016-08-20 01:16:40 +12:00
|
|
|
|
}
|
2016-08-19 22:32:27 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 21:59:46 +12:00
|
|
|
|
public override void OnDraw(Graphics g)
|
2016-11-30 09:06:54 +13:00
|
|
|
|
{
|
|
|
|
|
DrawImage(g);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void DrawImage(Graphics g)
|
2016-08-19 21:59:46 +12:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
2016-08-19 21:59: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;
|
2016-08-19 21:59:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 22:22:12 +12:00
|
|
|
|
|
2018-04-13 23:56:35 +12:00
|
|
|
|
public override void OnMoved()
|
|
|
|
|
{
|
2018-04-16 23:50:19 +12:00
|
|
|
|
/*if (Manager.Form.IsEditorMode)
|
2018-04-13 23:56:35 +12:00
|
|
|
|
{
|
2018-04-14 01:07:42 +12:00
|
|
|
|
Manager.AutoResizeCanvas();
|
2018-04-16 23:50:19 +12:00
|
|
|
|
}*/
|
2018-04-13 23:56:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 22:22:12 +12:00
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (Image != null)
|
|
|
|
|
{
|
|
|
|
|
Image.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 21:59:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|