mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Use bitmap in filter image effects
This commit is contained in:
parent
cfdad2c27c
commit
e419281240
16 changed files with 98 additions and 109 deletions
|
@ -35,12 +35,12 @@ namespace ShareX.HelpersLib
|
||||||
{
|
{
|
||||||
public static class ConvolutionMatrixManager
|
public static class ConvolutionMatrixManager
|
||||||
{
|
{
|
||||||
public static Image Apply(this ConvolutionMatrix kernel, Image img)
|
public static Bitmap Apply(this ConvolutionMatrix kernel, Bitmap bmp)
|
||||||
{
|
{
|
||||||
Bitmap result = (Bitmap)img.Clone();
|
Bitmap bmpResult = (Bitmap)bmp.Clone();
|
||||||
|
|
||||||
using (UnsafeBitmap source = new UnsafeBitmap((Bitmap)img, true, ImageLockMode.ReadOnly))
|
using (UnsafeBitmap source = new UnsafeBitmap(bmp, true, ImageLockMode.ReadOnly))
|
||||||
using (UnsafeBitmap dest = new UnsafeBitmap(result, true, ImageLockMode.WriteOnly))
|
using (UnsafeBitmap dest = new UnsafeBitmap(bmpResult, true, ImageLockMode.WriteOnly))
|
||||||
{
|
{
|
||||||
int originX = (kernel.Width - 1) / 2;
|
int originX = (kernel.Width - 1) / 2;
|
||||||
int originY = (kernel.Height - 1) / 2;
|
int originY = (kernel.Height - 1) / 2;
|
||||||
|
@ -96,23 +96,12 @@ public static Image Apply(this ConvolutionMatrix kernel, Image img)
|
||||||
a = a.Clamp(0, 255);
|
a = a.Clamp(0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.SetPixel(
|
dest.SetPixel(x, y, new ColorBgra((byte)b, (byte)g, (byte)r, kernel.ConsiderAlpha ? (byte)a : source.GetPixel(x, y).Alpha));
|
||||||
x,
|
|
||||||
y,
|
|
||||||
new ColorBgra(
|
|
||||||
(byte)b,
|
|
||||||
(byte)g,
|
|
||||||
(byte)r,
|
|
||||||
kernel.ConsiderAlpha
|
|
||||||
? (byte)a
|
|
||||||
: source.GetPixel(x, y).Alpha
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return bmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConvolutionMatrix Smooth(int weight = 1)
|
public static ConvolutionMatrix Smooth(int weight = 1)
|
||||||
|
|
|
@ -469,9 +469,9 @@ public static Image RoundedCorners(Image img, int cornerRadius)
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image Outline(Image img, int borderSize, Color borderColor)
|
public static Bitmap Outline(Bitmap bmp, int borderSize, Color borderColor)
|
||||||
{
|
{
|
||||||
Bitmap result = img.CreateEmptyBitmap(borderSize * 2, borderSize * 2);
|
Bitmap bmpResult = bmp.CreateEmptyBitmap(borderSize * 2, borderSize * 2);
|
||||||
|
|
||||||
ColorMatrix maskMatrix = new ColorMatrix();
|
ColorMatrix maskMatrix = new ColorMatrix();
|
||||||
maskMatrix.Matrix00 = 0;
|
maskMatrix.Matrix00 = 0;
|
||||||
|
@ -482,9 +482,9 @@ public static Image Outline(Image img, int borderSize, Color borderColor)
|
||||||
maskMatrix.Matrix41 = ((float)borderColor.G).Remap(0, 255, 0, 1);
|
maskMatrix.Matrix41 = ((float)borderColor.G).Remap(0, 255, 0, 1);
|
||||||
maskMatrix.Matrix42 = ((float)borderColor.B).Remap(0, 255, 0, 1);
|
maskMatrix.Matrix42 = ((float)borderColor.B).Remap(0, 255, 0, 1);
|
||||||
|
|
||||||
using (img)
|
using (bmp)
|
||||||
using (Image shadow = maskMatrix.Apply(img))
|
using (Image shadow = maskMatrix.Apply(bmp))
|
||||||
using (Graphics g = Graphics.FromImage(result))
|
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= borderSize * 2; i++)
|
for (int i = 0; i <= borderSize * 2; i++)
|
||||||
{
|
{
|
||||||
|
@ -494,33 +494,33 @@ public static Image Outline(Image img, int borderSize, Color borderColor)
|
||||||
g.DrawImage(shadow, new Rectangle(borderSize * 2, i, shadow.Width, shadow.Height));
|
g.DrawImage(shadow, new Rectangle(borderSize * 2, i, shadow.Width, shadow.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
g.DrawImage(img, new Rectangle(borderSize, borderSize, img.Width, img.Height));
|
g.DrawImage(bmp, new Rectangle(borderSize, borderSize, bmp.Width, bmp.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return bmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image DrawReflection(Image img, int percentage, int maxAlpha, int minAlpha, int offset, bool skew, int skewSize)
|
public static Bitmap DrawReflection(Bitmap bmp, int percentage, int maxAlpha, int minAlpha, int offset, bool skew, int skewSize)
|
||||||
{
|
{
|
||||||
Bitmap reflection = AddReflection(img, percentage, maxAlpha, minAlpha);
|
Bitmap reflection = AddReflection(bmp, percentage, maxAlpha, minAlpha);
|
||||||
|
|
||||||
if (skew)
|
if (skew)
|
||||||
{
|
{
|
||||||
reflection = AddSkew(reflection, skewSize, 0);
|
reflection = AddSkew(reflection, skewSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap result = new Bitmap(reflection.Width, img.Height + reflection.Height + offset);
|
Bitmap bmpResult = new Bitmap(reflection.Width, bmp.Height + reflection.Height + offset);
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(result))
|
using (bmp)
|
||||||
using (img)
|
|
||||||
using (reflection)
|
using (reflection)
|
||||||
|
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||||
{
|
{
|
||||||
g.SetHighQuality();
|
g.SetHighQuality();
|
||||||
g.DrawImage(img, 0, 0, img.Width, img.Height);
|
g.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height);
|
||||||
g.DrawImage(reflection, 0, img.Height + offset, reflection.Width, reflection.Height);
|
g.DrawImage(reflection, 0, bmp.Height + offset, reflection.Width, reflection.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return bmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap AddSkew(Image img, int x, int y)
|
public static Bitmap AddSkew(Image img, int x, int y)
|
||||||
|
@ -910,18 +910,18 @@ public static Bitmap RotateImage(Image img, float angleDegrees, bool upsize, boo
|
||||||
return newBitmap;
|
return newBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap AddShadow(Image img, float opacity, int size)
|
public static Bitmap AddShadow(Bitmap bmp, float opacity, int size)
|
||||||
{
|
{
|
||||||
return AddShadow(img, opacity, size, 1, Color.Black, new Point(0, 0));
|
return AddShadow(bmp, opacity, size, 1, Color.Black, new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap AddShadow(Image img, float opacity, int size, float darkness, Color color, Point offset)
|
public static Bitmap AddShadow(Bitmap bmp, float opacity, int size, float darkness, Color color, Point offset)
|
||||||
{
|
{
|
||||||
Bitmap shadowImage = null;
|
Bitmap shadowImage = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shadowImage = img.CreateEmptyBitmap(size * 2, size * 2);
|
shadowImage = bmp.CreateEmptyBitmap(size * 2, size * 2);
|
||||||
|
|
||||||
ColorMatrix maskMatrix = new ColorMatrix();
|
ColorMatrix maskMatrix = new ColorMatrix();
|
||||||
maskMatrix.Matrix00 = 0;
|
maskMatrix.Matrix00 = 0;
|
||||||
|
@ -932,8 +932,8 @@ public static Bitmap AddShadow(Image img, float opacity, int size, float darknes
|
||||||
maskMatrix.Matrix41 = ((float)color.G).Remap(0, 255, 0, 1);
|
maskMatrix.Matrix41 = ((float)color.G).Remap(0, 255, 0, 1);
|
||||||
maskMatrix.Matrix42 = ((float)color.B).Remap(0, 255, 0, 1);
|
maskMatrix.Matrix42 = ((float)color.B).Remap(0, 255, 0, 1);
|
||||||
|
|
||||||
Rectangle shadowRectangle = new Rectangle(size, size, img.Width, img.Height);
|
Rectangle shadowRectangle = new Rectangle(size, size, bmp.Width, bmp.Height);
|
||||||
maskMatrix.Apply(img, shadowImage, shadowRectangle);
|
maskMatrix.Apply(bmp, shadowImage, shadowRectangle);
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
|
@ -945,25 +945,25 @@ public static Bitmap AddShadow(Image img, float opacity, int size, float darknes
|
||||||
ColorMatrix alphaMatrix = new ColorMatrix();
|
ColorMatrix alphaMatrix = new ColorMatrix();
|
||||||
alphaMatrix.Matrix33 = darkness;
|
alphaMatrix.Matrix33 = darkness;
|
||||||
|
|
||||||
Bitmap shadowImage2 = (Bitmap)alphaMatrix.Apply(shadowImage);
|
Bitmap shadowImage2 = alphaMatrix.Apply(shadowImage);
|
||||||
shadowImage.Dispose();
|
shadowImage.Dispose();
|
||||||
shadowImage = shadowImage2;
|
shadowImage = shadowImage2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap result = shadowImage.CreateEmptyBitmap(Math.Abs(offset.X), Math.Abs(offset.Y));
|
Bitmap bmpResult = shadowImage.CreateEmptyBitmap(Math.Abs(offset.X), Math.Abs(offset.Y));
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(result))
|
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||||
{
|
{
|
||||||
g.SetHighQuality();
|
g.SetHighQuality();
|
||||||
g.DrawImage(shadowImage, Math.Max(0, offset.X), Math.Max(0, offset.Y), shadowImage.Width, shadowImage.Height);
|
g.DrawImage(shadowImage, Math.Max(0, offset.X), Math.Max(0, offset.Y), shadowImage.Width, shadowImage.Height);
|
||||||
g.DrawImage(img, Math.Max(size, -offset.X + size), Math.Max(size, -offset.Y + size), img.Width, img.Height);
|
g.DrawImage(bmp, Math.Max(size, -offset.X + size), Math.Max(size, -offset.Y + size), bmp.Width, bmp.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return bmpResult;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (img != null) img.Dispose();
|
if (bmp != null) bmp.Dispose();
|
||||||
if (shadowImage != null) shadowImage.Dispose();
|
if (shadowImage != null) shadowImage.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1416,17 +1416,17 @@ public static void FastBoxBlur(Bitmap bmp, int radius)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorStyles sides, bool curvedEdges)
|
public static Bitmap TornEdges(Bitmap bmp, int tornDepth, int tornRange, AnchorStyles sides, bool curvedEdges)
|
||||||
{
|
{
|
||||||
if (tornDepth < 1 || tornRange < 1 || sides == AnchorStyles.None)
|
if (tornDepth < 1 || tornRange < 1 || sides == AnchorStyles.None)
|
||||||
{
|
{
|
||||||
return img;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Point> points = new List<Point>();
|
List<Point> points = new List<Point>();
|
||||||
|
|
||||||
int horizontalTornCount = img.Width / tornRange;
|
int horizontalTornCount = bmp.Width / tornRange;
|
||||||
int verticalTornCount = img.Height / tornRange;
|
int verticalTornCount = bmp.Height / tornRange;
|
||||||
|
|
||||||
if (sides.HasFlag(AnchorStyles.Top))
|
if (sides.HasFlag(AnchorStyles.Top))
|
||||||
{
|
{
|
||||||
|
@ -1438,53 +1438,53 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
points.Add(new Point(0, 0));
|
points.Add(new Point(0, 0));
|
||||||
points.Add(new Point(img.Width - 1, 0));
|
points.Add(new Point(bmp.Width - 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sides.HasFlag(AnchorStyles.Right))
|
if (sides.HasFlag(AnchorStyles.Right))
|
||||||
{
|
{
|
||||||
for (int y = 0; y < verticalTornCount - 1; y++)
|
for (int y = 0; y < verticalTornCount - 1; y++)
|
||||||
{
|
{
|
||||||
points.Add(new Point(img.Width - 1 - MathHelpers.Random(0, tornDepth), tornRange * y));
|
points.Add(new Point(bmp.Width - 1 - MathHelpers.Random(0, tornDepth), tornRange * y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
points.Add(new Point(img.Width - 1, 0));
|
points.Add(new Point(bmp.Width - 1, 0));
|
||||||
points.Add(new Point(img.Width - 1, img.Height - 1));
|
points.Add(new Point(bmp.Width - 1, bmp.Height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sides.HasFlag(AnchorStyles.Bottom))
|
if (sides.HasFlag(AnchorStyles.Bottom))
|
||||||
{
|
{
|
||||||
for (int x = 0; x < horizontalTornCount - 1; x++)
|
for (int x = 0; x < horizontalTornCount - 1; x++)
|
||||||
{
|
{
|
||||||
points.Add(new Point(img.Width - 1 - (tornRange * x), img.Height - 1 - MathHelpers.Random(0, tornDepth)));
|
points.Add(new Point(bmp.Width - 1 - (tornRange * x), bmp.Height - 1 - MathHelpers.Random(0, tornDepth)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
points.Add(new Point(img.Width - 1, img.Height - 1));
|
points.Add(new Point(bmp.Width - 1, bmp.Height - 1));
|
||||||
points.Add(new Point(0, img.Height - 1));
|
points.Add(new Point(0, bmp.Height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sides.HasFlag(AnchorStyles.Left))
|
if (sides.HasFlag(AnchorStyles.Left))
|
||||||
{
|
{
|
||||||
for (int y = 0; y < verticalTornCount - 1; y++)
|
for (int y = 0; y < verticalTornCount - 1; y++)
|
||||||
{
|
{
|
||||||
points.Add(new Point(MathHelpers.Random(0, tornDepth), img.Height - 1 - (tornRange * y)));
|
points.Add(new Point(MathHelpers.Random(0, tornDepth), bmp.Height - 1 - (tornRange * y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
points.Add(new Point(0, img.Height - 1));
|
points.Add(new Point(0, bmp.Height - 1));
|
||||||
points.Add(new Point(0, 0));
|
points.Add(new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap result = img.CreateEmptyBitmap();
|
Bitmap bmpResult = bmp.CreateEmptyBitmap();
|
||||||
|
|
||||||
using (img)
|
using (bmp)
|
||||||
using (Graphics g = Graphics.FromImage(result))
|
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||||
using (TextureBrush brush = new TextureBrush(img))
|
using (TextureBrush brush = new TextureBrush(bmp))
|
||||||
{
|
{
|
||||||
g.SetHighQuality();
|
g.SetHighQuality();
|
||||||
|
|
||||||
|
@ -1498,22 +1498,22 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
|
||||||
{
|
{
|
||||||
g.FillPolygon(brush, fillPoints);
|
g.FillPolygon(brush, fillPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return bmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap Slice(Image img, int minSliceHeight, int maxSliceHeight, int minSliceShift, int maxSliceShift)
|
public static Bitmap Slice(Bitmap bmp, int minSliceHeight, int maxSliceHeight, int minSliceShift, int maxSliceShift)
|
||||||
{
|
{
|
||||||
Bitmap result = img.CreateEmptyBitmap();
|
Bitmap bmpResult = bmp.CreateEmptyBitmap();
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(result))
|
using (Graphics g = Graphics.FromImage(bmpResult))
|
||||||
{
|
{
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
while (y < img.Height)
|
while (y < bmp.Height)
|
||||||
{
|
{
|
||||||
Rectangle sourceRect = new Rectangle(0, y, img.Width, MathHelpers.Random(minSliceHeight, maxSliceHeight));
|
Rectangle sourceRect = new Rectangle(0, y, bmp.Width, MathHelpers.Random(minSliceHeight, maxSliceHeight));
|
||||||
Rectangle destRect = sourceRect;
|
Rectangle destRect = sourceRect;
|
||||||
|
|
||||||
if (MathHelpers.Random(1) == 0) // Shift left
|
if (MathHelpers.Random(1) == 0) // Shift left
|
||||||
|
@ -1525,13 +1525,13 @@ public static Bitmap Slice(Image img, int minSliceHeight, int maxSliceHeight, in
|
||||||
destRect.X = MathHelpers.Random(minSliceShift, maxSliceShift);
|
destRect.X = MathHelpers.Random(minSliceShift, maxSliceShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.DrawImage(img, destRect, sourceRect, GraphicsUnit.Pixel);
|
g.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
|
||||||
|
|
||||||
y += sourceRect.Height;
|
y += sourceRect.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return bmpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string OpenImageFileDialog(Form form = null)
|
public static string OpenImageFileDialog(Form form = null)
|
||||||
|
|
|
@ -56,10 +56,10 @@ public Blur()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
ImageHelpers.BoxBlur((Bitmap)img, Radius);
|
ImageHelpers.BoxBlur(bmp, Radius);
|
||||||
return img;
|
return bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,11 +32,11 @@ namespace ShareX.ImageEffectsLib
|
||||||
[Description("Edge detect")]
|
[Description("Edge detect")]
|
||||||
internal class EdgeDetect : ImageEffect
|
internal class EdgeDetect : ImageEffect
|
||||||
{
|
{
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ConvolutionMatrixManager.EdgeDetect().Apply(img);
|
return ConvolutionMatrixManager.EdgeDetect().Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ namespace ShareX.ImageEffectsLib
|
||||||
{
|
{
|
||||||
internal class Emboss : ImageEffect
|
internal class Emboss : ImageEffect
|
||||||
{
|
{
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ConvolutionMatrixManager.Emboss().Apply(img);
|
return ConvolutionMatrixManager.Emboss().Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public GaussianBlur()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
ConvolutionMatrix kernelHoriz = ConvolutionMatrixManager.GaussianBlur(1, size, sigma);
|
ConvolutionMatrix kernelHoriz = ConvolutionMatrixManager.GaussianBlur(1, size, sigma);
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ public override Image Apply(Image img)
|
||||||
kernelVert[i, 0] = kernelHoriz[0, i];
|
kernelVert[i, 0] = kernelHoriz[0, i];
|
||||||
}
|
}
|
||||||
|
|
||||||
using (img)
|
using (bmp)
|
||||||
using (Image horizPass = kernelHoriz.Apply(img))
|
using (Bitmap horizPass = kernelHoriz.Apply(bmp))
|
||||||
{
|
{
|
||||||
return kernelVert.Apply(horizPass);
|
return kernelVert.Apply(horizPass);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,9 @@ public MatrixConvolution()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
ConvolutionMatrix cm = new ConvolutionMatrix();
|
ConvolutionMatrix cm = new ConvolutionMatrix();
|
||||||
cm[0, 0] = X0Y0 / Factor;
|
cm[0, 0] = X0Y0 / Factor;
|
||||||
|
@ -79,7 +79,7 @@ public override Image Apply(Image img)
|
||||||
cm[2, 1] = X1Y2 / Factor;
|
cm[2, 1] = X1Y2 / Factor;
|
||||||
cm[2, 2] = X2Y2 / Factor;
|
cm[2, 2] = X2Y2 / Factor;
|
||||||
cm.Offset = Offset;
|
cm.Offset = Offset;
|
||||||
return cm.Apply(img);
|
return cm.Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,11 @@ namespace ShareX.ImageEffectsLib
|
||||||
[Description("Mean removal")]
|
[Description("Mean removal")]
|
||||||
internal class MeanRemoval : ImageEffect
|
internal class MeanRemoval : ImageEffect
|
||||||
{
|
{
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ConvolutionMatrixManager.MeanRemoval().Apply(img);
|
return ConvolutionMatrixManager.MeanRemoval().Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@ public Outline()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
return ImageHelpers.Outline(img, Size, Color);
|
return ImageHelpers.Outline(bmp, Size, Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,10 +51,10 @@ public Pixelate()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
ImageHelpers.Pixelate((Bitmap)img, Size);
|
ImageHelpers.Pixelate(bmp, Size);
|
||||||
return img;
|
return bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -90,9 +90,9 @@ public Reflection()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
return ImageHelpers.DrawReflection(img, Percentage, MaxAlpha, MinAlpha, Offset, Skew, SkewSize);
|
return ImageHelpers.DrawReflection(bmp, Percentage, MaxAlpha, MinAlpha, Offset, Skew, SkewSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -76,9 +76,9 @@ public Shadow()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
return ImageHelpers.AddShadow(img, Opacity, Size, Darkness + 1, Color, Offset);
|
return ImageHelpers.AddShadow(bmp, Opacity, Size, Darkness + 1, Color, Offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,13 +30,13 @@ namespace ShareX.ImageEffectsLib
|
||||||
{
|
{
|
||||||
internal class Sharpen : ImageEffect
|
internal class Sharpen : ImageEffect
|
||||||
{
|
{
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
//return ImageHelpers.Sharpen(img, Strength);
|
//return ImageHelpers.Sharpen(bmp, Strength);
|
||||||
|
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ConvolutionMatrixManager.Sharpen().Apply(img);
|
return ConvolutionMatrixManager.Sharpen().Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,16 +50,16 @@ public Slice()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
int minSliceHeight = Math.Min(MinSliceHeight, MaxSliceHeight);
|
int minSliceHeight = Math.Min(MinSliceHeight, MaxSliceHeight);
|
||||||
int maxSliceHeight = Math.Max(MinSliceHeight, MaxSliceHeight);
|
int maxSliceHeight = Math.Max(MinSliceHeight, MaxSliceHeight);
|
||||||
int minSliceShift = Math.Min(MinSliceShift, MaxSliceShift);
|
int minSliceShift = Math.Min(MinSliceShift, MaxSliceShift);
|
||||||
int maxSliceShift = Math.Max(MinSliceShift, MaxSliceShift);
|
int maxSliceShift = Math.Max(MinSliceShift, MaxSliceShift);
|
||||||
|
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ImageHelpers.Slice(img, minSliceHeight, maxSliceHeight, minSliceShift, maxSliceShift);
|
return ImageHelpers.Slice(bmp, minSliceHeight, maxSliceHeight, minSliceShift, maxSliceShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@ namespace ShareX.ImageEffectsLib
|
||||||
{
|
{
|
||||||
internal class Smooth : ImageEffect
|
internal class Smooth : ImageEffect
|
||||||
{
|
{
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
using (img)
|
using (bmp)
|
||||||
{
|
{
|
||||||
return ConvolutionMatrixManager.Smooth().Apply(img);
|
return ConvolutionMatrixManager.Smooth().Apply(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,9 @@ public TornEdge()
|
||||||
this.ApplyDefaultPropertyValues();
|
this.ApplyDefaultPropertyValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Image Apply(Image img)
|
public override Bitmap Apply(Bitmap bmp)
|
||||||
{
|
{
|
||||||
return ImageHelpers.TornEdges(img, Depth, Range, Sides, CurvedEdges);
|
return ImageHelpers.TornEdges(bmp, Depth, Range, Sides, CurvedEdges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue