Browse Source

Decode ICC profile into metadata

pull/2633/head
Ynse Hoornenborg 2 years ago
parent
commit
0301aed66d
  1. 10
      src/ImageSharp/Formats/Heif/Heif4CharCode.cs
  2. 2
      src/ImageSharp/Formats/Heif/Heif4CharCode.tt
  3. 12
      src/ImageSharp/Formats/Heif/HeifDecoderCore.cs

10
src/ImageSharp/Formats/Heif/Heif4CharCode.cs

@ -248,4 +248,14 @@ public enum Heif4CharCode : uint
/// </summary>
free = 0x66726565U,
/// <summary>
/// ICC Color Profile.
/// </summary>
rICC = 0x72494343U,
/// <summary>
/// ICC Color Profile.
/// </summary>
prof = 0x70726F66U,
}

2
src/ImageSharp/Formats/Heif/Heif4CharCode.tt

@ -54,6 +54,8 @@
"pict", "Picture handler type",
"uuid", "Unique Identifier",
"free", "Free space",
"rICC", "ICC Color Profile",
"prof", "ICC Color Profile",
};
#>

12
src/ImageSharp/Formats/Heif/HeifDecoderCore.cs

@ -7,6 +7,7 @@ using System.Text;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Heif;
@ -442,8 +443,17 @@ internal sealed class HeifDecoderCore : IImageDecoderInternals
properties.Add(new KeyValuePair<Heif4CharCode, object>(Heif4CharCode.pixi, new int[] { channelCount, bitsPerPixel }));
break;
case Heif4CharCode.altt:
case Heif4CharCode.colr:
Heif4CharCode profileType = (Heif4CharCode)BinaryPrimitives.ReadUInt32BigEndian(buffer);
if (profileType is Heif4CharCode.rICC or Heif4CharCode.prof)
{
byte[] iccData = new byte[itemLength - 4];
buffer[4..].CopyTo(iccData);
this.metadata.IccProfile = new IccProfile(iccData);
}
break;
case Heif4CharCode.altt:
case Heif4CharCode.imir:
case Heif4CharCode.irot:
case Heif4CharCode.iscl:

Loading…
Cancel
Save