Browse Source

Renamed enum to PngChunkFilter and also renamed enum names

pull/1574/head
Brian Popow 6 years ago
parent
commit
6407eef2e5
  1. 2
      src/ImageSharp/Formats/Png/IPngEncoderOptions.cs
  2. 24
      src/ImageSharp/Formats/Png/PngChunkFilter.cs
  3. 2
      src/ImageSharp/Formats/Png/PngEncoder.cs
  4. 10
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  5. 2
      src/ImageSharp/Formats/Png/PngEncoderOptions.cs
  6. 4
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

2
src/ImageSharp/Formats/Png/IPngEncoderOptions.cs

@ -61,6 +61,6 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// Gets the optimize method.
/// </summary>
PngOptimizeMethod? OptimizeMethod { get; }
PngChunkFilter? OptimizeMethod { get; }
}
}

24
src/ImageSharp/Formats/Png/PngOptimizeMethod.cs → src/ImageSharp/Formats/Png/PngChunkFilter.cs

@ -9,41 +9,41 @@ namespace SixLabors.ImageSharp.Formats.Png
/// Provides enumeration of available PNG optimization methods.
/// </summary>
[Flags]
public enum PngOptimizeMethod
public enum PngChunkFilter
{
/// <summary>
/// With the None filter, the scanline is transmitted unmodified.
/// With the None filter, all chunks will be written.
/// </summary>
None = 0,
/// <summary>
/// Suppress the physical dimension information chunk.
/// Excludes the physical dimension information chunk from encoding.
/// </summary>
SuppressPhysicalChunk = 1,
ExcludePhysicalChunk = 1 << 0,
/// <summary>
/// Suppress the gamma information chunk.
/// Excludes the gamma information chunk from encoding.
/// </summary>
SuppressGammaChunk = 2,
ExcludeGammaChunk = 1 << 1,
/// <summary>
/// Suppress the eXIf chunk.
/// Excludes the eXIf chunk from encoding.
/// </summary>
SuppressExifChunk = 4,
ExcludeExifChunk = 1 << 2,
/// <summary>
/// Suppress the tTXt, iTXt or zTXt chunk.
/// Excludes the tTXt, iTXt or zTXt chunk from encoding.
/// </summary>
SuppressTextChunks = 8,
ExcludeTextChunks = 1 << 3,
/// <summary>
/// Make funlly transparent pixels black.
/// Make fully transparent pixels black.
/// </summary>
MakeTransparentBlack = 16,
/// <summary>
/// All possible optimizations.
/// </summary>
All = 31,
ExcludeAll = ExcludePhysicalChunk | ExcludeGammaChunk | ExcludeExifChunk | ExcludeTextChunks
}
}

2
src/ImageSharp/Formats/Png/PngEncoder.cs

@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// Gets or sets the optimize method.
/// </summary>
public PngOptimizeMethod? OptimizeMethod { get; set; }
public PngChunkFilter? OptimizeMethod { get; set; }
/// <summary>
/// Encodes the image to the specified stream from the <see cref="Image{TPixel}"/>.

10
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Formats.Png
PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance);
PngEncoderOptionsHelpers.AdjustOptions<TPixel>(this.options, pngMetadata, out this.use16Bit, out this.bytesPerPixel);
IndexedImageFrame<TPixel> quantized;
if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.MakeTransparentBlack) == PngOptimizeMethod.MakeTransparentBlack)
if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.MakeTransparentBlack) == PngChunkFilter.MakeTransparentBlack)
{
using (Image<TPixel> tempImage = image.Clone())
{
@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.WriteHeaderChunk(stream);
if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressGammaChunk) != PngOptimizeMethod.SuppressGammaChunk)
if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeGammaChunk) != PngChunkFilter.ExcludeGammaChunk)
{
this.WriteGammaChunk(stream);
}
@ -190,17 +190,17 @@ namespace SixLabors.ImageSharp.Formats.Png
this.WritePaletteChunk(stream, quantized);
this.WriteTransparencyChunk(stream, pngMetadata);
if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressPhysicalChunk) != PngOptimizeMethod.SuppressPhysicalChunk)
if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludePhysicalChunk) != PngChunkFilter.ExcludePhysicalChunk)
{
this.WritePhysicalChunk(stream, metadata);
}
if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressExifChunk) != PngOptimizeMethod.SuppressExifChunk)
if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeExifChunk) != PngChunkFilter.ExcludeExifChunk)
{
this.WriteExifChunk(stream, metadata);
}
if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressTextChunks) != PngOptimizeMethod.SuppressTextChunks)
if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeTextChunks) != PngChunkFilter.ExcludeTextChunks)
{
this.WriteTextChunks(stream, pngMetadata);
}

2
src/ImageSharp/Formats/Png/PngEncoderOptions.cs

@ -83,6 +83,6 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// Gets or sets a the optimize method.
/// </summary>
public PngOptimizeMethod? OptimizeMethod { get; set; }
public PngChunkFilter? OptimizeMethod { get; set; }
}
}

4
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
appendPngColorType: true,
appendPixelType: true,
appendPngBitDepth: true,
optimizeMethod: PngOptimizeMethod.All);
optimizeMethod: PngChunkFilter.ExcludeAll);
}
}
@ -589,7 +589,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
bool appendCompressionLevel = false,
bool appendPaletteSize = false,
bool appendPngBitDepth = false,
PngOptimizeMethod optimizeMethod = PngOptimizeMethod.None)
PngChunkFilter optimizeMethod = PngChunkFilter.None)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())

Loading…
Cancel
Save