Browse Source

Update EuclideanPixelMap{TPixel}.cs

pull/1654/head
James Jackson-South 5 years ago
parent
commit
5b2d7c7397
  1. 17
      src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs

17
src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs

@ -116,11 +116,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
/// <summary> /// <summary>
/// A cache for storing color distance matching results. /// A cache for storing color distance matching results.
/// Not threadsafe but cache misses will be very rare and shouldn't
/// significantly negatively affect performance.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// The cache is limited to 646866 entries at 0.62MB. /// The cache is limited to 646866 entries at 0.62MB.
/// TODO: How do we make this threadsafe?
/// </remarks> /// </remarks>
private struct ColorDistanceCache private struct ColorDistanceCache
{ {
@ -169,13 +168,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
private static int GetPaletteIndex(int r, int g, int b, int a) private static int GetPaletteIndex(int r, int g, int b, int a)
=> (r << ((IndexBits * 2) + IndexAlphaBits)) => (r << ((IndexBits * 2) + IndexAlphaBits))
+ (r << (IndexBits + IndexAlphaBits + 1)) + (r << (IndexBits + IndexAlphaBits + 1))
+ (g << (IndexBits + IndexAlphaBits)) + (g << (IndexBits + IndexAlphaBits))
+ (r << (IndexBits * 2)) + (r << (IndexBits * 2))
+ (r << (IndexBits + 1)) + (r << (IndexBits + 1))
+ (g << IndexBits) + (g << IndexBits)
+ ((r + g + b) << IndexAlphaBits) + ((r + g + b) << IndexAlphaBits)
+ r + g + b + a; + r + g + b + a;
} }
} }
} }

Loading…
Cancel
Save