Browse Source

Fixing broken FastBitmap bug.

Former-commit-id: 758dac58be3ee77fc060fbf7eaa6b5ebe704b6aa
Former-commit-id: f2c9ffe5d7a61cbc5b500d6e565d1c71ae0adadd
Former-commit-id: 98b975796743b89e46d3cd03cea01f29d8ee8d26
pull/17/head
James South 11 years ago
parent
commit
f077eb39b7
  1. 149
      src/ImageProcessor.Playground/Program.cs
  2. 1
      src/ImageProcessor.Playground/images/input/tree.jpg.REMOVED.git-id
  3. 10
      src/ImageProcessor.Web.PostProcessor/PostProcessorBootstrapper.cs
  4. 8
      src/ImageProcessor.Web.PostProcessor/Settings.StyleCop
  5. 9
      src/ImageProcessor/Imaging/Convolution.cs
  6. 130
      src/ImageProcessor/Imaging/FastBitmap.cs
  7. 5
      src/ImageProcessor/Imaging/Filters/Artistic/HalftoneFilter.cs
  8. 4
      src/ImageProcessor/Imaging/Helpers/Adjustments.cs
  9. 1
      src/ImageProcessor/Imaging/Helpers/Effects.cs
  10. 3
      src/ImageProcessor/Settings.StyleCop

149
src/ImageProcessor.Playground/Program.cs

@ -60,7 +60,8 @@ namespace ImageProcessor.PlayGround
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "gamma-1.0-or-2.2.png")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "gamma-1.0-or-2.2.png"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "gamma_dalai_lama_gray.jpg")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "gamma_dalai_lama_gray.jpg"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "Arc-de-Triomphe-France.jpg")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "Arc-de-Triomphe-France.jpg"));
FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "Martin-Schoeller-Jack-Nicholson-Portrait.jpeg")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "Martin-Schoeller-Jack-Nicholson-Portrait.jpeg"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "tree.jpg"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "test2.png")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "test2.png"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "120430.gif")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "120430.gif"));
//FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "rickroll.original.gif")); //FileInfo fileInfo = new FileInfo(Path.Combine(resolvedPath, "rickroll.original.gif"));
@ -70,87 +71,89 @@ namespace ImageProcessor.PlayGround
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif");
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".png", ".jpg", ".jpeg"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".png", ".jpg", ".jpeg");
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".jpg", ".jpeg", ".jfif"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".jpg", ".jpeg", ".jfif");
//IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png"); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".png");
IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png");
//foreach (FileInfo fileInfo in files) foreach (FileInfo fileInfo in files)
//{ {
// if (fileInfo.Name == "test5.jpg") if (fileInfo.Name == "test5.jpg")
// { {
// continue; continue;
// } }
byte[] photoBytes = File.ReadAllBytes(fileInfo.FullName); byte[] photoBytes = File.ReadAllBytes(fileInfo.FullName);
Console.WriteLine("Processing: " + fileInfo.Name); Console.WriteLine("Processing: " + fileInfo.Name);
Stopwatch stopwatch = new Stopwatch(); Stopwatch stopwatch = new Stopwatch();
stopwatch.Start(); stopwatch.Start();
// ImageProcessor // ImageProcessor
using (MemoryStream inStream = new MemoryStream(photoBytes)) using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (ImageFactory imageFactory = new ImageFactory(true, false))
{ {
Size size = new Size(600, 0); using (ImageFactory imageFactory = new ImageFactory(true, true))
//CropLayer cropLayer = new CropLayer(20, 20, 20, 20, ImageProcessor.Imaging.CropMode.Percentage); {
//ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max, AnchorPosition.Center, false); Size size = new Size(600, 0);
//CropLayer cropLayer = new CropLayer(20, 20, 20, 20, ImageProcessor.Imaging.CropMode.Percentage);
//ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size) //ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max, AnchorPosition.Center, false);
//{
// ConvolutionType = ConvolutionType.Sobel //ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size)
//}; //{
// Load, resize, set the format and quality and save an image. // ConvolutionType = ConvolutionType.Sobel
imageFactory.Load(inStream) //};
//.DetectObjects(EmbeddedHaarCascades.FrontFaceDefault) // Load, resize, set the format and quality and save an image.
//.Overlay(new ImageLayer imageFactory.Load(inStream)
// { //.DetectObjects(EmbeddedHaarCascades.FrontFaceDefault)
// Image = overlay, //.Overlay(new ImageLayer
// Opacity = 50 // {
// }) // Image = overlay,
//.Alpha(50) // Opacity = 50
//.BackgroundColor(Color.White) // })
//.Resize(new Size((int)(size.Width * 1.1), 0)) //.Alpha(50)
//.ContentAwareResize(layer) //.BackgroundColor(Color.White)
//.Constrain(size) //.Resize(new Size((int)(size.Width * 1.1), 0))
//.Mask(mask) //.ContentAwareResize(layer)
//.Format(new PngFormat()) //.Constrain(size)
//.BackgroundColor(Color.Cyan) //.Mask(mask)
//.ReplaceColor(Color.FromArgb(255, 223, 224), Color.FromArgb(121, 188, 255), 128) //.Format(new PngFormat())
//.GaussianSharpen(3) //.BackgroundColor(Color.Cyan)
//.Saturation(20) //.ReplaceColor(Color.FromArgb(255, 223, 224), Color.FromArgb(121, 188, 255), 128)
.Resize(size) //.GaussianSharpen(3)
//.Resize(new ResizeLayer(size, ResizeMode.Max)) //.Saturation(20)
// .Resize(new ResizeLayer(size, ResizeMode.Stretch)) //.Resize(size)
//.DetectEdges(new Laplacian3X3EdgeFilter(), true) //.Resize(new ResizeLayer(size, ResizeMode.Max))
//.DetectEdges(new LaplacianOfGaussianEdgeFilter()) // .Resize(new ResizeLayer(size, ResizeMode.Stretch))
//.GaussianBlur(new GaussianLayer(10, 11)) //.DetectEdges(new SobelEdgeFilter(), true)
//.EntropyCrop() //.DetectEdges(new LaplacianOfGaussianEdgeFilter())
//.Halftone() //.GaussianBlur(new GaussianLayer(10, 11))
//.RotateBounded(150, false) //.EntropyCrop()
//.Crop(cropLayer) .Halftone()
//.Rotate(140) //.RotateBounded(150, false)
//.Filter(MatrixFilters.Invert) //.Crop(cropLayer)
//.Contrast(50) //.Rotate(140)
//.Filter(MatrixFilters.Comic) //.Filter(MatrixFilters.Invert)
//.Flip() //.Brightness(-5)
//.Filter(MatrixFilters.HiSatch) //.Contrast(50)
//.Pixelate(8) //.Filter(MatrixFilters.Comic)
//.GaussianSharpen(10) //.Flip()
//.Format(new PngFormat() { IsIndexed = true }) //.Filter(MatrixFilters.HiSatch)
//.Format(new PngFormat() ) //.Pixelate(8)
.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); //.GaussianSharpen(10)
//.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".png"))); //.Format(new PngFormat() { IsIndexed = true })
//.Format(new PngFormat() )
stopwatch.Stop(); .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name)));
//.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".png")));
stopwatch.Stop();
}
} }
}
long peakWorkingSet64 = Process.GetCurrentProcess().PeakWorkingSet64; long peakWorkingSet64 = Process.GetCurrentProcess().PeakWorkingSet64;
float mB = peakWorkingSet64 / (float)1024 / 1024; float mB = peakWorkingSet64 / (float)1024 / 1024;
Console.WriteLine(@"Completed {0} in {1:s\.fff} secs {2}Peak memory usage was {3} bytes or {4} Mb.", fileInfo.Name, stopwatch.Elapsed, Environment.NewLine, peakWorkingSet64.ToString("#,#"), mB); Console.WriteLine(@"Completed {0} in {1:s\.fff} secs {2}Peak memory usage was {3} bytes or {4} Mb.", fileInfo.Name, stopwatch.Elapsed, Environment.NewLine, peakWorkingSet64.ToString("#,#"), mB);
//Console.WriteLine("Processed: " + fileInfo.Name + " in " + stopwatch.ElapsedMilliseconds + "ms"); //Console.WriteLine("Processed: " + fileInfo.Name + " in " + stopwatch.ElapsedMilliseconds + "ms");
//} }
Console.ReadLine(); Console.ReadLine();
} }

1
src/ImageProcessor.Playground/images/input/tree.jpg.REMOVED.git-id

@ -0,0 +1 @@
f5e8e6f09d2e518da37e698b6113b82e8f21dcd1

10
src/ImageProcessor.Web.PostProcessor/PostProcessorBootstrapper.cs

@ -58,11 +58,11 @@ namespace ImageProcessor.Web.PostProcessor
// Get the resources and copy them across. // Get the resources and copy them across.
Dictionary<string, string> resources = new Dictionary<string, string> Dictionary<string, string> resources = new Dictionary<string, string>
{ {
{"gifsicle.exe","ImageProcessor.Web.PostProcessor.Resources.Unmanaged." + folder + ".gifsicle.exe"}, { "gifsicle.exe", "ImageProcessor.Web.PostProcessor.Resources.Unmanaged." + folder + ".gifsicle.exe" },
{"jpegtran.exe","ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.jpegtran.exe"}, { "jpegtran.exe", "ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.jpegtran.exe" },
{"optipng.exe","ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.optipng.exe"}, { "optipng.exe", "ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.optipng.exe" },
{"pngout.exe","ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.pngout.exe"}, { "pngout.exe", "ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.pngout.exe" },
{"png.cmd","ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.png.cmd" } { "png.cmd", "ImageProcessor.Web.PostProcessor.Resources.Unmanaged.x86.png.cmd" }
}; };
// Write the files out to the bin folder. // Write the files out to the bin folder.

8
src/ImageProcessor.Web.PostProcessor/Settings.StyleCop

@ -1 +1,7 @@
<StyleCopSettings Version="105" /> <StyleCopSettings Version="105">
<GlobalSettings>
<CollectionProperty Name="RecognizedWords">
<Value>executables</Value>
</CollectionProperty>
</GlobalSettings>
</StyleCopSettings>

9
src/ImageProcessor/Imaging/Convolution.cs

@ -335,10 +335,6 @@ namespace ImageProcessor.Imaging
green += k * color.G; green += k * color.G;
blue += k * color.B; blue += k * color.B;
alpha += k * color.A; alpha += k * color.A;
//red += k * (color.R * color.R);
//green += k * (color.G * color.G);
//blue += k * (color.B * color.B);
//alpha += k * (color.A * color.A);
processedKernelSize++; processedKernelSize++;
} }
@ -364,11 +360,6 @@ namespace ImageProcessor.Imaging
// Check and apply the divider // Check and apply the divider
if ((long)divider != 0) if ((long)divider != 0)
{ {
//red = Math.Sqrt(red / divider);
//green = Math.Sqrt(green / divider);
//blue = Math.Sqrt(blue / divider);
//alpha = Math.Sqrt(alpha / divider);
red /= divider; red /= divider;
green /= divider; green /= divider;
blue /= divider; blue /= divider;

130
src/ImageProcessor/Imaging/FastBitmap.cs

@ -22,6 +22,30 @@ namespace ImageProcessor.Imaging
/// </summary> /// </summary>
public unsafe class FastBitmap : IDisposable public unsafe class FastBitmap : IDisposable
{ {
/// <summary>
/// The integral representation of the 8bppIndexed pixel format.
/// </summary>
// ReSharper disable once InconsistentNaming
private const int Format8bppIndexed = (int)PixelFormat.Format8bppIndexed;
/// <summary>
/// The integral representation of the 24bppRgb pixel format.
/// </summary>
// ReSharper disable once InconsistentNaming
private const int Format24bppRgb = (int)PixelFormat.Format24bppRgb;
/// <summary>
/// The integral representation of the 32bppArgb pixel format.
/// </summary>
// ReSharper disable once InconsistentNaming
private const int Format32bppArgb = (int)PixelFormat.Format32bppArgb;
/// <summary>
/// The integral representation of the 32bppPArgb pixel format.
/// </summary>
// ReSharper disable once InconsistentNaming
private const int Format32bppPArgb = (int)PixelFormat.Format32bppPArgb;
/// <summary> /// <summary>
/// The bitmap. /// The bitmap.
/// </summary> /// </summary>
@ -37,11 +61,6 @@ namespace ImageProcessor.Imaging
/// </summary> /// </summary>
private readonly int height; private readonly int height;
/// <summary>
/// The size of the a single pixel.
/// </summary>
private readonly int pixelSize;
/// <summary> /// <summary>
/// The color channel - blue, green, red, alpha. /// The color channel - blue, green, red, alpha.
/// </summary> /// </summary>
@ -55,27 +74,27 @@ namespace ImageProcessor.Imaging
/// <summary> /// <summary>
/// The normal integral image. /// The normal integral image.
/// </summary> /// </summary>
private readonly long[,] normalSumImage; private long[,] normalSumImage;
/// <summary> /// <summary>
/// The squared integral image. /// The squared integral image.
/// </summary> /// </summary>
private readonly long[,] squaredSumImage; private long[,] squaredSumImage;
/// <summary> /// <summary>
/// The tilted sum image. /// The tilted sum image.
/// </summary> /// </summary>
private readonly long[,] tiltedSumImage; private long[,] tiltedSumImage;
/// <summary> /// <summary>
/// The normal width. /// The normal width.
/// </summary> /// </summary>
private readonly int normalWidth; private int normalWidth;
/// <summary> /// <summary>
/// The tilted width. /// The tilted width.
/// </summary> /// </summary>
private readonly int tiltedWidth; private int tiltedWidth;
/// <summary> /// <summary>
/// The number of bytes in a row. /// The number of bytes in a row.
@ -112,6 +131,11 @@ namespace ImageProcessor.Imaging
/// </summary> /// </summary>
private GCHandle tiltedSumHandle; private GCHandle tiltedSumHandle;
/// <summary>
/// The size of the color32 structure.
/// </summary>
private int pixelSize;
/// <summary> /// <summary>
/// The bitmap data. /// The bitmap data.
/// </summary> /// </summary>
@ -153,46 +177,25 @@ namespace ImageProcessor.Imaging
/// </param> /// </param>
public FastBitmap(Image bitmap, bool computeTilted) public FastBitmap(Image bitmap, bool computeTilted)
{ {
int pixelFormat = (int)bitmap.PixelFormat;
// Check image format // Check image format
if (!(bitmap.PixelFormat == PixelFormat.Format8bppIndexed || if (!(pixelFormat == Format8bppIndexed ||
bitmap.PixelFormat == PixelFormat.Format24bppRgb || pixelFormat == Format24bppRgb ||
bitmap.PixelFormat == PixelFormat.Format32bppArgb || pixelFormat == Format32bppArgb ||
bitmap.PixelFormat == PixelFormat.Format32bppPArgb)) pixelFormat == Format32bppPArgb))
{ {
throw new ArgumentException("Only 8bpp, 24bpp and 32bpp images are supported."); throw new ArgumentException("Only 8bpp, 24bpp and 32bpp images are supported.");
} }
this.pixelSize = Image.GetPixelFormatSize(bitmap.PixelFormat) / 8;
this.bitmap = (Bitmap)bitmap; this.bitmap = (Bitmap)bitmap;
this.width = this.bitmap.Width; this.width = this.bitmap.Width;
this.height = this.bitmap.Height; this.height = this.bitmap.Height;
this.channel = this.bitmap.PixelFormat == PixelFormat.Format8bppIndexed ? 0 : 2;
this.computeTilted = computeTilted;
this.normalWidth = this.width + 1;
int normalHeight = this.height + 1;
this.tiltedWidth = this.width + 2;
int tiltedHeight = this.height + 2;
this.normalSumImage = new long[normalHeight, this.normalWidth];
this.normalSumHandle = GCHandle.Alloc(this.normalSumImage, GCHandleType.Pinned);
this.normalSum = (long*)this.normalSumHandle.AddrOfPinnedObject().ToPointer();
this.squaredSumImage = new long[normalHeight, this.normalWidth]; this.channel = pixelFormat == Format8bppIndexed ? 0 : 2;
this.squaredSumHandle = GCHandle.Alloc(this.squaredSumImage, GCHandleType.Pinned); this.computeTilted = computeTilted;
this.squaredSum = (long*)this.squaredSumHandle.AddrOfPinnedObject().ToPointer();
if (this.computeTilted)
{
this.tiltedSumImage = new long[tiltedHeight, this.tiltedWidth];
this.tiltedSumHandle = GCHandle.Alloc(this.tiltedSumImage, GCHandleType.Pinned);
this.tiltedSum = (long*)this.tiltedSumHandle.AddrOfPinnedObject().ToPointer();
}
this.LockBitmap(); this.LockBitmap();
this.CalculateIntegrals();
} }
/// <summary> /// <summary>
@ -260,13 +263,13 @@ namespace ImageProcessor.Imaging
/// <summary> /// <summary>
/// Allows the implicit conversion of an instance of <see cref="FastBitmap"/> to a /// Allows the implicit conversion of an instance of <see cref="FastBitmap"/> to a
/// <see cref="Image"/>. /// <see cref="System.Drawing.Image"/>.
/// </summary> /// </summary>
/// <param name="fastBitmap"> /// <param name="fastBitmap">
/// The instance of <see cref="FastBitmap"/> to convert. /// The instance of <see cref="FastBitmap"/> to convert.
/// </param> /// </param>
/// <returns> /// <returns>
/// An instance of <see cref="Image"/>. /// An instance of <see cref="System.Drawing.Image"/>.
/// </returns> /// </returns>
public static implicit operator Image(FastBitmap fastBitmap) public static implicit operator Image(FastBitmap fastBitmap)
{ {
@ -308,14 +311,7 @@ namespace ImageProcessor.Imaging
} }
#endif #endif
Color32* data = this[x, y]; Color32* data = this[x, y];
return Color.FromArgb(data->A, data->R, data->G, data->B);
if (this.bitmap.PixelFormat == PixelFormat.Format32bppArgb ||
this.bitmap.PixelFormat == PixelFormat.Format32bppPArgb)
{
return Color.FromArgb(data->A, data->R, data->G, data->B);
}
return Color.FromArgb(data->R, data->G, data->B);
} }
/// <summary> /// <summary>
@ -344,12 +340,7 @@ namespace ImageProcessor.Imaging
data->R = color.R; data->R = color.R;
data->G = color.G; data->G = color.G;
data->B = color.B; data->B = color.B;
data->A = color.A;
if (this.bitmap.PixelFormat == PixelFormat.Format32bppArgb ||
this.bitmap.PixelFormat == PixelFormat.Format32bppPArgb)
{
data->A = color.A;
}
} }
/// <summary> /// <summary>
@ -511,6 +502,7 @@ namespace ImageProcessor.Imaging
// Figure out the number of bytes in a row. This is rounded up to be a multiple // Figure out the number of bytes in a row. This is rounded up to be a multiple
// of 4 bytes, since a scan line in an image must always be a multiple of 4 bytes // of 4 bytes, since a scan line in an image must always be a multiple of 4 bytes
// in length. // in length.
this.pixelSize = Image.GetPixelFormatSize(this.bitmap.PixelFormat) / 8;
this.bytesInARow = bounds.Width * this.pixelSize; this.bytesInARow = bounds.Width * this.pixelSize;
if (this.bytesInARow % 4 != 0) if (this.bytesInARow % 4 != 0)
{ {
@ -518,10 +510,34 @@ namespace ImageProcessor.Imaging
} }
// Lock the bitmap // Lock the bitmap
this.bitmapData = this.bitmap.LockBits(bounds, ImageLockMode.ReadWrite, this.bitmap.PixelFormat); this.bitmapData = this.bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
// Set the value to the first scan line // Set the value to the first scan line
this.pixelBase = (byte*)this.bitmapData.Scan0.ToPointer(); this.pixelBase = (byte*)this.bitmapData.Scan0.ToPointer();
// Allocate values for integral image calculation.
this.normalWidth = this.width + 1;
int normalHeight = this.height + 1;
this.tiltedWidth = this.width + 2;
int tiltedHeight = this.height + 2;
this.normalSumImage = new long[normalHeight, this.normalWidth];
this.normalSumHandle = GCHandle.Alloc(this.normalSumImage, GCHandleType.Pinned);
this.normalSum = (long*)this.normalSumHandle.AddrOfPinnedObject().ToPointer();
this.squaredSumImage = new long[normalHeight, this.normalWidth];
this.squaredSumHandle = GCHandle.Alloc(this.squaredSumImage, GCHandleType.Pinned);
this.squaredSum = (long*)this.squaredSumHandle.AddrOfPinnedObject().ToPointer();
if (this.computeTilted)
{
this.tiltedSumImage = new long[tiltedHeight, this.tiltedWidth];
this.tiltedSumHandle = GCHandle.Alloc(this.tiltedSumImage, GCHandleType.Pinned);
this.tiltedSum = (long*)this.tiltedSumHandle.AddrOfPinnedObject().ToPointer();
}
this.CalculateIntegrals();
} }
/// <summary> /// <summary>
@ -638,4 +654,4 @@ namespace ImageProcessor.Imaging
this.pixelBase = null; this.pixelBase = null;
} }
} }
} }

5
src/ImageProcessor/Imaging/Filters/Artistic/HalftoneFilter.cs

@ -200,7 +200,8 @@ namespace ImageProcessor.Imaging.Filters.Artistic
// Yellow oversaturates the output. // Yellow oversaturates the output.
int offset = this.distance; int offset = this.distance;
float yellowMultiplier = this.distance * 1.667f; float yellowMultiplier = this.distance * 1.334f;
float magentaMultiplier = this.distance * 1.667f;
float multiplier = this.distance * 2.2f; float multiplier = this.distance * 2.2f;
float max = this.distance * (float)Math.Sqrt(2); float max = this.distance * (float)Math.Sqrt(2);
@ -289,7 +290,7 @@ namespace ImageProcessor.Imaging.Filters.Artistic
{ {
color = sourceBitmap.GetPixel(angledX, angledY); color = sourceBitmap.GetPixel(angledX, angledY);
cmykColor = color; cmykColor = color;
brushWidth = Math.Min((cmykColor.M / 100f) * multiplier, max); brushWidth = Math.Min((cmykColor.M / 100f) * magentaMultiplier, max);
graphicsMagenta.FillEllipse(magentaBrush, angledX, angledY, brushWidth, brushWidth); graphicsMagenta.FillEllipse(magentaBrush, angledX, angledY, brushWidth, brushWidth);
} }

4
src/ImageProcessor/Imaging/Helpers/Adjustments.cs

@ -15,8 +15,6 @@ namespace ImageProcessor.Imaging.Helpers
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Threading.Tasks; using System.Threading.Tasks;
using ImageProcessor.Common.Extensions;
/// <summary> /// <summary>
/// Provides reusable adjustment methods to apply to images. /// Provides reusable adjustment methods to apply to images.
/// </summary> /// </summary>
@ -97,7 +95,7 @@ namespace ImageProcessor.Imaging.Helpers
} }
float brightnessFactor = (float)threshold / 100; float brightnessFactor = (float)threshold / 100;
Rectangle bounds = rectangle.HasValue ? rectangle.Value : new Rectangle(0, 0, source.Width, source.Height); Rectangle bounds = rectangle ?? new Rectangle(0, 0, source.Width, source.Height);
ColorMatrix colorMatrix = ColorMatrix colorMatrix =
new ColorMatrix( new ColorMatrix(

1
src/ImageProcessor/Imaging/Helpers/Effects.cs

@ -235,6 +235,7 @@ namespace ImageProcessor.Imaging.Helpers
// Darken it again to average out the color. // Darken it again to average out the color.
destination = Adjustments.Brightness(destination, -5); destination = Adjustments.Brightness(destination, -5);
return (Bitmap)destination; return (Bitmap)destination;
} }
} }

3
src/ImageProcessor/Settings.StyleCop

@ -2,7 +2,9 @@
<GlobalSettings> <GlobalSettings>
<CollectionProperty Name="RecognizedWords"> <CollectionProperty Name="RecognizedWords">
<Value>Accord</Value> <Value>Accord</Value>
<Value>argb</Value>
<Value>bitstream</Value> <Value>bitstream</Value>
<Value>bpp</Value>
<Value>dd</Value> <Value>dd</Value>
<Value>ddd</Value> <Value>ddd</Value>
<Value>dllimport</Value> <Value>dllimport</Value>
@ -13,6 +15,7 @@
<Value>mmmm</Value> <Value>mmmm</Value>
<Value>orig</Value> <Value>orig</Value>
<Value>quantizable</Value> <Value>quantizable</Value>
<Value>rgb</Value>
<Value>Scharr</Value> <Value>Scharr</Value>
<Value>Sobel</Value> <Value>Sobel</Value>
<Value>specifier</Value> <Value>specifier</Value>

Loading…
Cancel
Save