Browse Source

Cleanup

af/merge-core
James Jackson-South 9 years ago
parent
commit
056588aef4
  1. 4
      src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs
  2. 11
      src/ImageSharp/Dithering/Ordered/Bayer.cs
  3. 11
      src/ImageSharp/Dithering/Ordered/Ordered.cs
  4. 2
      src/ImageSharp/Quantizers/Octree/OctreeQuantizer.cs
  5. 6
      src/ImageSharp/Quantizers/Quantize.cs
  6. 2
      tests/ImageSharp.Tests/Formats/Png/PngTests.cs

4
src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs

@ -1,4 +1,4 @@
// <copyright file="ErrorDiffusionDitherProcessor.cs" company="James Jackson-South">
// <copyright file="OrderedDitherProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -18,7 +18,7 @@ namespace ImageSharp.Processing.Processors
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
/// <summary>
/// Initializes a new instance of the <see cref="ErrorDiffusionDitherProcessor{TColor}"/> class.
/// Initializes a new instance of the <see cref="OrderedDitherProcessor{TColor}"/> class.
/// </summary>
/// <param name="dither">The ordered ditherer.</param>
/// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param>

11
src/ImageSharp/Dithering/Ordered/Bayer.cs

@ -17,11 +17,12 @@ namespace ImageSharp.Dithering.Ordered
/// The threshold matrix.
/// This is calculated by multiplying each value in the original matrix by 16 and subtracting 1
/// </summary>
private static readonly byte[,] ThresholdMatrix = {
{ 15, 143, 47, 175 },
{ 207, 79, 239, 111 },
{ 63, 191, 31, 159 },
{ 255, 127, 223, 95 }
private static readonly byte[,] ThresholdMatrix =
{
{ 15, 143, 47, 175 },
{ 207, 79, 239, 111 },
{ 63, 191, 31, 159 },
{ 255, 127, 223, 95 }
};
/// <inheritdoc />

11
src/ImageSharp/Dithering/Ordered/Ordered.cs

@ -17,11 +17,12 @@ namespace ImageSharp.Dithering.Ordered
/// The threshold matrix.
/// This is calculated by multiplying each value in the original matrix by 16
/// </summary>
private static readonly byte[,] ThresholdMatrix = {
{ 0, 128, 32, 160 },
{ 192, 64, 224, 96 },
{ 48, 176, 16, 144 },
{ 240, 112, 208, 80 }
private static readonly byte[,] ThresholdMatrix =
{
{ 0, 128, 32, 160 },
{ 192, 64, 224, 96 },
{ 48, 176, 16, 144 },
{ 240, 112, 208, 80 }
};
/// <inheritdoc />

2
src/ImageSharp/Quantizers/Octree/OctreeQuantizer.cs

@ -437,7 +437,7 @@ namespace ImageSharp.Quantizers
{
if (this.leaf)
{
// TODO: Test Vector4 here
// This seems faster than using Vector4
byte r = (this.red / this.pixelCount).ToByte();
byte g = (this.green / this.pixelCount).ToByte();
byte b = (this.blue / this.pixelCount).ToByte();

6
src/ImageSharp/Quantizers/Quantize.cs

@ -57,8 +57,6 @@ namespace ImageSharp
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
QuantizedImage<TColor> quantized = quantizer.Quantize(source, maxColors);
int pixelCount = quantized.Pixels.Length;
int palleteCount = quantized.Palette.Length - 1;
using (PixelAccessor<TColor> pixels = new PixelAccessor<TColor>(quantized.Width, quantized.Height))
@ -69,9 +67,9 @@ namespace ImageSharp
source.Configuration.ParallelOptions,
y =>
{
for (var x = 0; x < pixels.Width; x++)
for (int x = 0; x < pixels.Width; x++)
{
var i = x + (y * pixels.Width);
int i = x + (y * pixels.Width);
TColor color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])];
pixels[x, y] = color;
}

2
tests/ImageSharp.Tests/Formats/Png/PngTests.cs

@ -19,7 +19,7 @@ namespace ImageSharp.Tests
[Fact]
public void ImageCanSaveIndexedPng()
{
string path = CreateOutputDirectory("Png");
string path = CreateOutputDirectory("Png", "Indexed");
foreach (TestFile file in Files)
{

Loading…
Cancel
Save