Browse Source

AppHeadMarker

af/merge-core
James Jackson-South 9 years ago
parent
commit
fb94270e07
  1. 16
      src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs
  2. 22
      tests/ImageSharp.Tests/FileTestBase.cs

16
src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs

@ -361,7 +361,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
break;
case OrigJpegConstants.Markers.APP0:
this.ProcessApplicationHeader(remaining);
this.ProcessApplicationHeaderMarker(remaining);
break;
case OrigJpegConstants.Markers.APP1:
this.ProcessApp1Marker(remaining);
@ -558,7 +558,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
/// Processes the application header containing the JFIF identifier plus extra data.
/// </summary>
/// <param name="remaining">The remaining bytes in the segment block.</param>
private void ProcessApplicationHeader(int remaining)
private void ProcessApplicationHeaderMarker(int remaining)
{
if (remaining < 5)
{
@ -569,14 +569,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
this.InputProcessor.ReadFull(this.Temp, 0, 13);
remaining -= 13;
// TODO: We should be using constants for this.
this.isJfif = this.Temp[0] == 'J' && this.Temp[1] == 'F' && this.Temp[2] == 'I' && this.Temp[3] == 'F'
&& this.Temp[4] == '\x00';
this.isJfif = this.Temp[0] == OrigJpegConstants.JFif.J &&
this.Temp[1] == OrigJpegConstants.JFif.F &&
this.Temp[2] == OrigJpegConstants.JFif.I &&
this.Temp[3] == OrigJpegConstants.JFif.F &&
this.Temp[4] == OrigJpegConstants.JFif.Null;
if (this.isJfif)
{
this.horizontalResolution = (short)(this.Temp[9] + (this.Temp[8] << 8));
this.verticalResolution = (short)(this.Temp[11] + (this.Temp[10] << 8));
this.horizontalResolution = (short)((this.Temp[8] << 8) | this.Temp[9]);
this.verticalResolution = (short)((this.Temp[10] << 8) | this.Temp[11]);
}
if (remaining > 0)

22
tests/ImageSharp.Tests/FileTestBase.cs

@ -70,17 +70,17 @@ namespace SixLabors.ImageSharp.Tests
protected static readonly List<TestFile> Files = new List<TestFile>
{
TestFile.Create(TestImages.Jpeg.Baseline.Calliphora),
// TestFile.Create(TestImages.Jpeg.Baseline.Turtle), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Ycck), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Cmyk), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Floorplan), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Festzug), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Bad.MissingEOF), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.Bad.ExifUndefType), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Fb), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Progress), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Baseline.GammaDalaiLamaGray), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Jpeg.Progressive.Bad.BadEOF), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Turtle), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Ycck), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Cmyk), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Floorplan), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Progressive.Festzug), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Bad.BadEOF), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.Bad.ExifUndefType), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Progressive.Fb), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Progressive.Progress), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Baseline.GammaDalaiLamaGray), // Perf: Enable for local testing only
TestFile.Create(TestImages.Jpeg.Progressive.Bad.BadEOF), // Perf: Enable for local testing only
TestFile.Create(TestImages.Bmp.Car),
// TestFile.Create(TestImages.Bmp.NegHeight), // Perf: Enable for local testing only
// TestFile.Create(TestImages.Bmp.CoreHeader), // Perf: Enable for local testing only

Loading…
Cancel
Save