Browse Source

Start work on jpeg 12 bit support

af/merge-core
Stephan Vedder 7 years ago
parent
commit
51ed7c7191
  1. 10
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  2. 5
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs
  3. 4
      tests/ImageSharp.Tests/TestImages.cs
  4. 3
      tests/Images/Input/Jpg/baseline/testorig12.jpg

10
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <summary>
/// The only supported precision
/// </summary>
public const int SupportedPrecision = 8;
public readonly int[] SupportedPrecisions = { 8, 12 };
/// <summary>
/// The global configuration
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <summary>
/// Gets the color depth, in number of bits per pixel.
/// </summary>
public int BitsPerPixel => this.ComponentCount * SupportedPrecision;
public int BitsPerPixel => this.ComponentCount * this.Frame.Precision;
/// <summary>
/// Gets the input stream.
@ -720,10 +720,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
this.InputStream.Read(this.temp, 0, remaining);
// We only support 8-bit precision.
if (this.temp[0] != SupportedPrecision)
// We only support 8-bit and 12-bit precision.
if (!SupportedPrecisions.Contains(this.temp[0]))
{
throw new ImageFormatException("Only 8-Bit precision supported.");
throw new ImageFormatException("Only 8-Bit and 12-Bit precision supported.");
}
this.Frame = new JpegFrame

5
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs

@ -28,7 +28,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
TestImages.Jpeg.Issues.ExifResizeOutOfRange696,
TestImages.Jpeg.Issues.InvalidAPP0721,
TestImages.Jpeg.Issues.ExifGetString750Load,
TestImages.Jpeg.Issues.ExifGetString750Transform
TestImages.Jpeg.Issues.ExifGetString750Transform,
// High depth images
TestImages.Jpeg.Baseline.Testorig12bit,
};
public static string[] ProgressiveTestJpegs =

4
tests/ImageSharp.Tests/TestImages.cs

@ -135,12 +135,14 @@ namespace SixLabors.ImageSharp.Tests
public const string Testorig420 = "Jpg/baseline/testorig.jpg";
public const string MultiScanBaselineCMYK = "Jpg/baseline/MultiScanBaselineCMYK.jpg";
public const string Ratio1x1 = "Jpg/baseline/ratio-1x1.jpg";
public const string Testorig12bit = "Jpg/baseline/testorig12.jpg";
public static readonly string[] All =
{
Cmyk, Ycck, Exif, Floorplan,
Calliphora, Turtle, GammaDalaiLamaGray,
Hiyamugi, Jpeg400, Jpeg420Exif, Jpeg444, Ratio1x1
Hiyamugi, Jpeg400, Jpeg420Exif, Jpeg444,
Ratio1x1, Testorig12bit
};
}

3
tests/Images/Input/Jpg/baseline/testorig12.jpg

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