Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Gif/GifEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
ImageMetaData metaData = image.MetaData;
this.gifMetaData = metaData.GetFormatMetaData(GifFormat.Instance);
this.colorTableMode = this.colorTableMode ?? this.gifMetaData.ColorTableMode;
bool useGlobalTable = this.colorTableMode.Equals(GifColorTableMode.Global);
bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global;

// Quantize the image returning a palette.
QuantizedFrame<TPixel> quantized =
Expand Down
10 changes: 5 additions & 5 deletions src/ImageSharp/Formats/Png/PngEncoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public PngEncoderCore(MemoryAllocator memoryAllocator, IPngEncoderOptions option
this.pngColorType = options.ColorType;

// Specification recommends default filter method None for paletted images and Paeth for others.
this.pngFilterMethod = options.FilterMethod ?? (options.ColorType.Equals(PngColorType.Palette)
this.pngFilterMethod = options.FilterMethod ?? (options.ColorType == PngColorType.Palette
? PngFilterMethod.None
: PngFilterMethod.Paeth);
this.compressionLevel = options.CompressionLevel;
Expand Down Expand Up @@ -217,7 +217,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
this.writeGamma = this.gamma > 0;
this.pngColorType = this.pngColorType ?? pngMetaData.ColorType;
this.pngBitDepth = this.pngBitDepth ?? pngMetaData.BitDepth;
this.use16Bit = this.pngBitDepth.Equals(PngBitDepth.Bit16);
this.use16Bit = this.pngBitDepth == PngBitDepth.Bit16;

// Ensure we are not allowing impossible combinations.
if (!ColorTypes.ContainsKey(this.pngColorType.Value))
Expand Down Expand Up @@ -329,7 +329,7 @@ private void CollectGrayscaleBytes<TPixel>(ReadOnlySpan<TPixel> rowSpan)
Span<byte> rawScanlineSpan = this.rawScanline.GetSpan();
ref byte rawScanlineSpanRef = ref MemoryMarshal.GetReference(rawScanlineSpan);

if (this.pngColorType.Equals(PngColorType.Grayscale))
if (this.pngColorType == PngColorType.Grayscale)
{
if (this.use16Bit)
{
Expand Down Expand Up @@ -761,7 +761,7 @@ private void WriteGammaChunk(Stream stream)
private void WriteTransparencyChunk(Stream stream, PngMetaData pngMetaData)
{
Span<byte> alpha = this.chunkDataBuffer.AsSpan();
if (pngMetaData.ColorType.Equals(PngColorType.Rgb))
if (pngMetaData.ColorType == PngColorType.Rgb)
{
if (pngMetaData.TransparentRgb48.HasValue && this.use16Bit)
{
Expand All @@ -782,7 +782,7 @@ private void WriteTransparencyChunk(Stream stream, PngMetaData pngMetaData)
this.WriteChunk(stream, PngChunkType.Transparency, this.chunkDataBuffer, 0, 6);
}
}
else if (pngMetaData.ColorType.Equals(PngColorType.Grayscale))
else if (pngMetaData.ColorType == PngColorType.Grayscale)
{
if (pngMetaData.TransparentGray16.HasValue && this.use16Bit)
{
Expand Down