mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Added Blur-delegate, this makes it possible to supply a quicker implementation of a blur from a plug-in... kinda hackish...
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2537 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
7a4ac7e4f9
commit
8943549eaf
1 changed files with 11 additions and 4 deletions
|
@ -38,6 +38,10 @@ namespace GreenshotPlugin.Core {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageHelper));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageHelper));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
|
|
||||||
|
// This delegate makes it possible that a plug-in delivers a quicker Blur implementation
|
||||||
|
public delegate void BlurDelegate(Bitmap bitmap, int radius);
|
||||||
|
public static BlurDelegate BlurReplacement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a thumbnail from an image
|
/// Create a thumbnail from an image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -741,13 +745,14 @@ namespace GreenshotPlugin.Core {
|
||||||
if ((shadowSize & 1) == 0) {
|
if ((shadowSize & 1) == 0) {
|
||||||
shadowSize++;
|
shadowSize++;
|
||||||
}
|
}
|
||||||
bool canUseGDIBlur = GDIplus.isBlurPossible(shadowSize);
|
bool useGDIBlur = GDIplus.isBlurPossible(shadowSize);
|
||||||
|
bool useBlurDelegate = BlurReplacement != null;
|
||||||
// Create "mask" for the shadow
|
// Create "mask" for the shadow
|
||||||
ColorMatrix maskMatrix = new ColorMatrix();
|
ColorMatrix maskMatrix = new ColorMatrix();
|
||||||
maskMatrix.Matrix00 = 0;
|
maskMatrix.Matrix00 = 0;
|
||||||
maskMatrix.Matrix11 = 0;
|
maskMatrix.Matrix11 = 0;
|
||||||
maskMatrix.Matrix22 = 0;
|
maskMatrix.Matrix22 = 0;
|
||||||
if (canUseGDIBlur) {
|
if (useGDIBlur || useBlurDelegate) {
|
||||||
maskMatrix.Matrix33 = darkness + 0.1f;
|
maskMatrix.Matrix33 = darkness + 0.1f;
|
||||||
} else {
|
} else {
|
||||||
maskMatrix.Matrix33 = darkness;
|
maskMatrix.Matrix33 = darkness;
|
||||||
|
@ -756,10 +761,12 @@ namespace GreenshotPlugin.Core {
|
||||||
ApplyColorMatrix((Bitmap)sourceBitmap, Rectangle.Empty, returnImage, shadowRectangle, maskMatrix);
|
ApplyColorMatrix((Bitmap)sourceBitmap, Rectangle.Empty, returnImage, shadowRectangle, maskMatrix);
|
||||||
|
|
||||||
// blur "shadow", apply to whole new image
|
// blur "shadow", apply to whole new image
|
||||||
if (canUseGDIBlur) {
|
if (useBlurDelegate) {
|
||||||
|
BlurReplacement(returnImage, shadowSize+1);
|
||||||
|
} else if (useGDIBlur) {
|
||||||
// Use GDI Blur
|
// Use GDI Blur
|
||||||
Rectangle newImageRectangle = new Rectangle(0, 0, returnImage.Width, returnImage.Height);
|
Rectangle newImageRectangle = new Rectangle(0, 0, returnImage.Width, returnImage.Height);
|
||||||
GDIplus.ApplyBlur(returnImage, newImageRectangle, shadowSize, false);
|
GDIplus.ApplyBlur(returnImage, newImageRectangle, shadowSize+1, false);
|
||||||
} else {
|
} else {
|
||||||
// try normal software blur
|
// try normal software blur
|
||||||
//returnImage = CreateBlur(returnImage, newImageRectangle, true, shadowSize, 1d, false, newImageRectangle);
|
//returnImage = CreateBlur(returnImage, newImageRectangle, true, shadowSize, 1d, false, newImageRectangle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue