mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Small fixes for the Zoom and its performance improvements
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2285 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
831a3b4d5b
commit
9ca5f0d3bd
3 changed files with 43 additions and 6 deletions
1
Greenshot/Forms/CaptureForm.Designer.cs
generated
1
Greenshot/Forms/CaptureForm.Designer.cs
generated
|
@ -59,7 +59,6 @@ namespace Greenshot.Forms {
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(0, 0);
|
||||
this.Cursor = System.Windows.Forms.Cursors.Cross;
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "CaptureForm";
|
||||
this.ShowIcon = false;
|
||||
|
|
|
@ -81,6 +81,17 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This should prevent childs to draw backgrounds
|
||||
/// </summary>
|
||||
protected override CreateParams CreateParams {
|
||||
get {
|
||||
CreateParams cp = base.CreateParams;
|
||||
cp.ExStyle |= 0x02000000;
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
|
||||
public CaptureForm(ICapture capture, List<WindowDetails> windows) {
|
||||
if (currentForm != null) {
|
||||
LOG.Debug("Found currentForm, Closing already opened CaptureForm");
|
||||
|
@ -105,6 +116,8 @@ namespace Greenshot.Forms {
|
|||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent();
|
||||
// Only double-buffer when we are not in a TerminalServerSession
|
||||
this.DoubleBuffered = !System.Windows.Forms.SystemInformation.TerminalServerSession;
|
||||
this.Text = "Greenshot capture form";
|
||||
|
||||
// Make sure we never capture the captureform
|
||||
|
@ -367,7 +380,14 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This makes sure there is no background painted, as we have complete "paint" control it doesn't make sense to do otherwise.
|
||||
/// </summary>
|
||||
/// <param name="pevent"></param>
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent) {
|
||||
}
|
||||
|
||||
void OnPaint(object sender, PaintEventArgs e) {
|
||||
Graphics graphics = e.Graphics;
|
||||
Rectangle clipRectangle = e.ClipRectangle;
|
||||
|
|
|
@ -45,6 +45,17 @@ namespace Greenshot.Forms {
|
|||
Zoom = 400;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevent the clipping of the child (this Form is a child of another)
|
||||
/// </summary>
|
||||
protected override CreateParams CreateParams {
|
||||
get {
|
||||
var parms = base.CreateParams;
|
||||
parms.Style &= ~0x02000000; // Turn off WS_CLIPCHILDREN
|
||||
return parms;
|
||||
}
|
||||
}
|
||||
|
||||
public Point MouseLocation {
|
||||
get {
|
||||
return mouseLocation;
|
||||
|
@ -74,6 +85,12 @@ namespace Greenshot.Forms {
|
|||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// This makes sure there is no background painted, as we have complete "paint" control it doesn't make sense to do otherwise.
|
||||
/// </summary>
|
||||
/// <param name="pevent"></param>
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent) {
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) {
|
||||
if (captureToZoom == null || captureToZoom.Image == null) {
|
||||
|
@ -83,13 +100,13 @@ namespace Greenshot.Forms {
|
|||
graphics.SmoothingMode = SmoothingMode.None;
|
||||
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
graphics.CompositingQuality = CompositingQuality.HighSpeed;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
Rectangle clipRectangle = e.ClipRectangle;
|
||||
float zoom = (float)100 / (float)Zoom;
|
||||
|
||||
int sourceWidth = (int)(Width * zoom);
|
||||
int sourceHeight = (int)(Height * zoom);
|
||||
Rectangle sourceRectangle = new Rectangle(MouseLocation.X - (sourceHeight / 2), MouseLocation.Y - (sourceHeight / 2), sourceWidth, sourceHeight);
|
||||
Rectangle sourceRectangle = new Rectangle(MouseLocation.X - (sourceWidth / 2), MouseLocation.Y - (sourceHeight / 2), sourceWidth, sourceHeight);
|
||||
Rectangle destinationRectangle = new Rectangle(0, 0, Width, Height);
|
||||
graphics.DrawImage(captureToZoom.Image, destinationRectangle, sourceRectangle, GraphicsUnit.Pixel);
|
||||
|
||||
|
@ -115,11 +132,12 @@ namespace Greenshot.Forms {
|
|||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.ClientSize = new System.Drawing.Size(100, 100);
|
||||
this.ControlBox = false;
|
||||
this.DoubleBuffered = true;
|
||||
// Only double-buffer when we are not in a TerminalServerSession
|
||||
this.DoubleBuffered = !System.Windows.Forms.SystemInformation.TerminalServerSession;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new Size(50, 50);
|
||||
this.MinimumSize = ClientSize;
|
||||
this.Name = "Zoom";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue