Browse Source

Fix issue with decoding VP8 alpha channel: Use8BDecode will only be set to true, if there is a transform present

pull/1552/head
Brian Popow 6 years ago
parent
commit
86d8b6fea7
  1. 2
      src/ImageSharp/Formats/WebP/AlphaDecoder.cs
  2. 1
      tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs
  3. 1
      tests/ImageSharp.Tests/TestImages.cs
  4. 3
      tests/Images/Input/WebP/1602311202.webp

2
src/ImageSharp/Formats/WebP/AlphaDecoder.cs

@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
var bitReader = new Vp8LBitReader(data);
this.LosslessDecoder = new WebPLosslessDecoder(bitReader, memoryAllocator, configuration);
this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true);
this.Use8BDecode = Is8BOptimizable(this.Vp8LDec.Metadata);
this.Use8BDecode = this.Vp8LDec.Transforms.Count > 0 && Is8BOptimizable(this.Vp8LDec.Metadata);
}
}

1
tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs

@ -181,6 +181,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
[WithFile(Lossy.Alpha1, PixelTypes.Rgba32)]
[WithFile(Lossy.Alpha2, PixelTypes.Rgba32)]
[WithFile(Lossy.Alpha3, PixelTypes.Rgba32)]
[WithFile(Lossy.AlphaThinkingSmiley, PixelTypes.Rgba32)]
public void WebpDecoder_CanDecode_Lossy_WithAlpha<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{

1
tests/ImageSharp.Tests/TestImages.cs

@ -640,6 +640,7 @@ namespace SixLabors.ImageSharp.Tests
public const string AlphaCompressedVerticalFilter = "WebP/alpha_filter_2_method_1.webp";
public const string AlphaNoCompressionGradientFilter = "WebP/alpha_filter_3_method_0.webp";
public const string AlphaCompressedGradientFilter = "WebP/alpha_filter_3_method_1.webp";
public const string AlphaThinkingSmiley = "WebP/1602311202.webp";
}
}
}

3
tests/Images/Input/WebP/1602311202.webp

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4dac76bec0e5b23a988b0f2221e9b20e63dc207ef48f33e49a4336a874e2a915
size 18406
Loading…
Cancel
Save