mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Cleanup, and fixed a bug in the CloneArea method of the ImageHelper.cs
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2506 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
652ca64e9f
commit
ec5840550a
4 changed files with 29 additions and 12 deletions
|
@ -56,12 +56,11 @@ namespace Greenshot.Drawing {
|
||||||
get { return cursor; }
|
get { return cursor; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// The bulk of the clean-up code is implemented in Dispose(bool)
|
/// <summary>
|
||||||
|
/// This Dispose is called from the Dispose and the Destructor.
|
||||||
/**
|
/// When disposing==true all non-managed resources should be freed too!
|
||||||
* This Dispose is called from the Dispose and the Destructor.
|
/// </summary>
|
||||||
* When disposing==true all non-managed resources should be freed too!
|
/// <param name="disposing"></param>
|
||||||
*/
|
|
||||||
protected override void Dispose(bool disposing) {
|
protected override void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
|
|
@ -128,6 +128,14 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <param name="graphics">Graphics</param>
|
/// <param name="graphics">Graphics</param>
|
||||||
/// <param name="destinationRect">Rectangle with destination</param>
|
/// <param name="destinationRect">Rectangle with destination</param>
|
||||||
void DrawTo(Graphics graphics, Rectangle destinationRect);
|
void DrawTo(Graphics graphics, Rectangle destinationRect);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return true if the coordinates are inside the FastBitmap
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool Contains(int x, int y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -416,6 +424,16 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// returns true if x & y are inside the FastBitmap
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <returns>true if x & y are inside the FastBitmap</returns>
|
||||||
|
public bool Contains(int x, int y) {
|
||||||
|
return x >= 0 && x < Width && y >= 0 && y < Height;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract Color GetColorAt(int x, int y);
|
public abstract Color GetColorAt(int x, int y);
|
||||||
public abstract void SetColorAt(int x, int y, Color color);
|
public abstract void SetColorAt(int x, int y, Color color);
|
||||||
public abstract void GetColorAt(int x, int y, byte[] color);
|
public abstract void GetColorAt(int x, int y, byte[] color);
|
||||||
|
|
|
@ -1197,6 +1197,8 @@ namespace GreenshotPlugin.Core {
|
||||||
// Make sure the source is not Rectangle.Empty
|
// Make sure the source is not Rectangle.Empty
|
||||||
if (Rectangle.Empty.Equals(sourceRect)) {
|
if (Rectangle.Empty.Equals(sourceRect)) {
|
||||||
sourceRect = new Rectangle(0, 0, sourceImage.Width, sourceImage.Height);
|
sourceRect = new Rectangle(0, 0, sourceImage.Width, sourceImage.Height);
|
||||||
|
} else {
|
||||||
|
sourceRect.Intersect(bitmapRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no pixelformat is supplied
|
// If no pixelformat is supplied
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
return (IntPtr)FIELD_INFO_NATIVE_IMAGEATTRIBUTES.GetValue(imageAttributes);
|
return (IntPtr)FIELD_INFO_NATIVE_IMAGEATTRIBUTES.GetValue(imageAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool canApply(int radius) {
|
private static bool isBlurPossible(int radius) {
|
||||||
if (Environment.OSVersion.Version.Major < 6) {
|
if (Environment.OSVersion.Version.Major < 6) {
|
||||||
return false;
|
return false;
|
||||||
} else if ((Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2) && radius < 20) {
|
} else if ((Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2) && radius < 20) {
|
||||||
|
@ -183,8 +183,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
/// <param name="expandEdges">bool true if the edges are expanded with the radius</param>
|
/// <param name="expandEdges">bool true if the edges are expanded with the radius</param>
|
||||||
/// <returns>false if there is no GDI+ available or an exception occured</returns>
|
/// <returns>false if there is no GDI+ available or an exception occured</returns>
|
||||||
public static bool ApplyBlur(Bitmap destinationBitmap, Rectangle area, int radius, bool expandEdges) {
|
public static bool ApplyBlur(Bitmap destinationBitmap, Rectangle area, int radius, bool expandEdges) {
|
||||||
if (!canApply(radius))
|
if (!isBlurPossible(radius)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IntPtr hBlurParams = IntPtr.Zero;
|
IntPtr hBlurParams = IntPtr.Zero;
|
||||||
|
@ -238,8 +237,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>false if there is no GDI+ available or an exception occured</returns>
|
/// <returns>false if there is no GDI+ available or an exception occured</returns>
|
||||||
public static bool DrawWithBlur(Graphics graphics, Bitmap image, Rectangle source, Matrix transform, ImageAttributes imageAttributes, int radius, bool expandEdges) {
|
public static bool DrawWithBlur(Graphics graphics, Bitmap image, Rectangle source, Matrix transform, ImageAttributes imageAttributes, int radius, bool expandEdges) {
|
||||||
if (!canApply(radius))
|
if (!isBlurPossible(radius)) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +277,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
// Everything worked, return true
|
// Everything worked, return true
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.Error("Problem using GdipBitmapApplyEffect: ", ex);
|
LOG.Error("Problem using GdipDrawImageFX: ", ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (hEffect != null) {
|
if (hEffect != null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue