2019-05-02 21:45:54 +12:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2023-01-10 09:31:02 +13:00
|
|
|
|
Copyright (c) 2007-2023 ShareX Team
|
2019-05-02 21:45:54 +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)
|
|
|
|
|
|
2020-07-06 11:23:59 +12:00
|
|
|
|
using ShareX.HelpersLib;
|
2019-05-02 21:45:54 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
|
|
|
|
public class MagnifyDrawingShape : EllipseDrawingShape
|
|
|
|
|
{
|
|
|
|
|
public override ShapeType ShapeType { get; } = ShapeType.DrawingMagnify;
|
|
|
|
|
|
|
|
|
|
public int MagnifyStrength { get; set; } = 200;
|
2020-07-06 11:23:59 +12:00
|
|
|
|
public ImageInterpolationMode ImageInterpolationMode { get; set; }
|
2019-05-02 21:45:54 +12:00
|
|
|
|
|
2019-05-03 20:01:09 +12:00
|
|
|
|
public MagnifyDrawingShape()
|
|
|
|
|
{
|
|
|
|
|
ForceProportionalResizing = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-03 19:40:54 +12:00
|
|
|
|
public override void OnConfigLoad()
|
|
|
|
|
{
|
|
|
|
|
base.OnConfigLoad();
|
|
|
|
|
MagnifyStrength = AnnotationOptions.MagnifyStrength;
|
2019-05-05 18:53:03 +12:00
|
|
|
|
ImageInterpolationMode = AnnotationOptions.ImageInterpolationMode;
|
2019-05-03 19:40:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnConfigSave()
|
|
|
|
|
{
|
|
|
|
|
base.OnConfigSave();
|
|
|
|
|
AnnotationOptions.MagnifyStrength = MagnifyStrength;
|
2019-05-05 18:53:03 +12:00
|
|
|
|
AnnotationOptions.ImageInterpolationMode = ImageInterpolationMode;
|
2019-05-03 19:40:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 21:45:54 +12:00
|
|
|
|
public override void OnDraw(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
g.PixelOffsetMode = PixelOffsetMode.Half;
|
2020-07-06 11:23:59 +12:00
|
|
|
|
g.InterpolationMode = ImageHelpers.GetInterpolationMode(ImageInterpolationMode);
|
2019-05-02 21:45:54 +12:00
|
|
|
|
|
|
|
|
|
using (GraphicsPath gp = new GraphicsPath())
|
|
|
|
|
{
|
|
|
|
|
gp.AddEllipse(Rectangle);
|
|
|
|
|
g.SetClip(gp);
|
|
|
|
|
|
2019-05-03 19:44:04 +12:00
|
|
|
|
float magnify = Math.Max(MagnifyStrength, 100) / 100f;
|
2019-05-02 21:45:54 +12:00
|
|
|
|
int newWidth = (int)(Rectangle.Width / magnify);
|
|
|
|
|
int newHeight = (int)(Rectangle.Height / magnify);
|
|
|
|
|
|
|
|
|
|
g.DrawImage(Manager.Form.Canvas, Rectangle,
|
2022-02-20 19:30:39 +13:00
|
|
|
|
new RectangleF(Rectangle.X + (Rectangle.Width / 2) - (newWidth / 2) - Manager.Form.CanvasRectangle.X + Manager.RenderOffset.X,
|
2019-08-22 02:28:17 +12:00
|
|
|
|
Rectangle.Y + (Rectangle.Height / 2) - (newHeight / 2) - Manager.Form.CanvasRectangle.Y + Manager.RenderOffset.Y,
|
2019-05-02 21:45:54 +12:00
|
|
|
|
newWidth, newHeight), GraphicsUnit.Pixel);
|
|
|
|
|
|
|
|
|
|
g.ResetClip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g.PixelOffsetMode = PixelOffsetMode.Default;
|
|
|
|
|
g.InterpolationMode = InterpolationMode.Bilinear;
|
|
|
|
|
|
|
|
|
|
DrawEllipse(g);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-30 01:05:47 +13:00
|
|
|
|
}
|