-
-
Notifications
You must be signed in to change notification settings - Fork 888
ICC Improvements #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICC Improvements #588
Changes from 5 commits
b133dc7
35f6b73
72c5548
800ee09
70a52db
df7fa40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,7 +266,7 @@ public void ParseStream(Stream stream, bool metadataOnly = false) | |
| { | ||
| // It's highly unlikely that APPn related data will be found after the SOS marker | ||
| // We should have gathered everything we need by now. | ||
| return; | ||
| break; | ||
| } | ||
|
|
||
| case JpegConstants.Markers.DHT: | ||
|
|
@@ -345,6 +345,11 @@ public void ParseStream(Stream stream, bool metadataOnly = false) | |
| // Read on. | ||
| fileMarker = FindNextFileMarker(this.markerBuffer, this.InputStream); | ||
| } | ||
|
|
||
| if (this.MetaData.IccProfile?.CheckIsValid() == false) | ||
|
||
| { | ||
| this.MetaData.IccProfile = null; | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) Six Labors and contributors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System; | ||
| using SixLabors.ImageSharp.MetaData.Profiles.Icc; | ||
| using Xunit; | ||
|
|
||
| namespace SixLabors.ImageSharp.Tests.Icc | ||
| { | ||
| public class IccProfileTests | ||
| { | ||
|
|
||
| #if !NETSTANDARD1_1 | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(IccTestDataProfiles.ProfileIdTestData), MemberType = typeof(IccTestDataProfiles))] | ||
| public void CalculateHash_WithByteArray_CalculatesProfileHash(byte[] data, IccProfileId expected) | ||
| { | ||
| IccProfileId result = IccProfile.CalculateHash(data); | ||
|
|
||
| Assert.Equal(expected, result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CalculateHash_WithByteArray_DoesNotModifyData() | ||
| { | ||
| byte[] data = IccTestDataProfiles.Profile_Random_Array; | ||
| byte[] copy = new byte[data.Length]; | ||
| Buffer.BlockCopy(data, 0, copy, 0, data.Length); | ||
|
|
||
| IccProfileId result = IccProfile.CalculateHash(data); | ||
|
|
||
| Assert.Equal(data, copy); | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] | ||
| public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) | ||
| { | ||
| var profile = new IccProfile(data); | ||
|
|
||
| bool result = profile.CheckIsValid(); | ||
|
|
||
| Assert.Equal(expected, result); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to
InitDerivedMetaDataProperties