Browse Source

Comments, quantization table scaling with clamp call

pull/1706/head
Dmitry Pentin 5 years ago
parent
commit
c64ac5f8ec
  1. 15
      src/ImageSharp/Formats/Jpeg/Components/Quantization.cs
  2. 7
      src/ImageSharp/Formats/Jpeg/JpegMetadata.cs

15
src/ImageSharp/Formats/Jpeg/Components/Quantization.cs

@ -179,19 +179,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
Block8x8F table = default;
for (int j = 0; j < Block8x8F.Size; j++)
{
int x = unscaledTable[j];
x = ((x * scale) + 50) / 100;
if (x < 1)
{
x = 1;
}
if (x > 255)
{
x = 255;
}
table[j] = x;
int x = ((unscaledTable[j] * scale) + 50) / 100;
table[j] = Numerics.Clamp(x, 1, 255);
}
return table;

7
src/ImageSharp/Formats/Jpeg/JpegMetadata.cs

@ -11,7 +11,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// </summary>
public class JpegMetadata : IDeepCloneable
{
/// <summary>
/// Backing field for <see cref="LuminanceQuality"/>
/// </summary>
private int? luminanceQuality;
/// <summary>
/// Backing field for <see cref="ChrominanceQuality"/>
/// </summary>
private int? chrominanceQuality;
/// <summary>

Loading…
Cancel
Save