Browse Source
Premultiply only if alpha representation is unknown or Unassociated
pull/1773/head
Anton Firszov
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
2 deletions
-
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs
|
|
|
@ -188,8 +188,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
|
bool compand, |
|
|
|
bool premultiplyAlpha) |
|
|
|
{ |
|
|
|
bool pixelHasNoAlpha = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.AlphaRepresentation == PixelAlphaRepresentation.None; |
|
|
|
premultiplyAlpha &= !pixelHasNoAlpha; |
|
|
|
PixelAlphaRepresentation? alphaRepresentation = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.PixelAlphaRepresentation; |
|
|
|
|
|
|
|
// Premultiply only if alpha representation is unknown or Unassociated:
|
|
|
|
bool needsPremultiplication = alphaRepresentation == null || alphaRepresentation.Value == PixelAlphaRepresentation.Unassociated; |
|
|
|
premultiplyAlpha &= needsPremultiplication; |
|
|
|
PixelConversionModifiers conversionModifiers = GetModifiers(compand, premultiplyAlpha); |
|
|
|
|
|
|
|
Buffer2DRegion<TPixel> sourceRegion = source.PixelBuffer.GetRegion(sourceRectangle); |
|
|
|
|