Browse Source

Premultiply only if alpha representation is unknown or Unassociated

pull/1773/head
Anton Firszov 5 years ago
committed by GitHub
parent
commit
6d9a04d38c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

7
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

@ -188,8 +188,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
bool compand, bool compand,
bool premultiplyAlpha) bool premultiplyAlpha)
{ {
bool pixelHasNoAlpha = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.AlphaRepresentation == PixelAlphaRepresentation.None; PixelAlphaRepresentation? alphaRepresentation = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.PixelAlphaRepresentation;
premultiplyAlpha &= !pixelHasNoAlpha;
// Premultiply only if alpha representation is unknown or Unassociated:
bool needsPremultiplication = alphaRepresentation == null || alphaRepresentation.Value == PixelAlphaRepresentation.Unassociated;
premultiplyAlpha &= needsPremultiplication;
PixelConversionModifiers conversionModifiers = GetModifiers(compand, premultiplyAlpha); PixelConversionModifiers conversionModifiers = GetModifiers(compand, premultiplyAlpha);
Buffer2DRegion<TPixel> sourceRegion = source.PixelBuffer.GetRegion(sourceRectangle); Buffer2DRegion<TPixel> sourceRegion = source.PixelBuffer.GetRegion(sourceRectangle);

Loading…
Cancel
Save