Table of Contents

Class HeicImage

Namespace
Egami.Heic
Assembly
Egami.Heic.dll

Reads the images a HEIC file holds besides the one Load gives: thumbnails, depth maps, gain maps and other auxiliary images, such as an iPhone's portrait and sky mattes. Items lists them.

public static class HeicImage
Inheritance
HeicImage
Inherited Members

Examples

// The other images a photo holds: thumbnails, gain maps, depth maps and mattes (portrait, skin, sky).
HeicDetails details = (HeicDetails)sdr.Metadata.FormatDetails!;
HeicItem sky = details.Items.First(i => i.AuxiliaryType == "urn:com:apple:photo:2020:aux:semanticskymatte");
using Raster matte = HeicImage.ReadItem("portrait.heic", sky.Id, context: heic);
matte.Apply(ops => ops.AutoOrient());
matte.Save("sky-matte.png");

Methods

ReadItem(Stream, uint, ReaderOptions?, EgamiContext?)

Reads image item itemId from a stream; see ReadItem(string, uint, ReaderOptions?, EgamiContext?).

public static Raster ReadItem(Stream stream, uint itemId, ReaderOptions? options = null, EgamiContext? context = null)

Parameters

stream Stream

The file's data, from its start.

itemId uint

The item's id.

options ReaderOptions

The general options; the frame range is ignored.

context EgamiContext

The context, or null for Default. Egami.Heic reads the item whether or not the context registers it.

Returns

Raster

The image. The caller must dispose it.

Examples

// The other images a photo holds: thumbnails, gain maps, depth maps and mattes (portrait, skin, sky).
HeicDetails details = (HeicDetails)sdr.Metadata.FormatDetails!;
HeicItem sky = details.Items.First(i => i.AuxiliaryType == "urn:com:apple:photo:2020:aux:semanticskymatte");
using Raster matte = HeicImage.ReadItem("portrait.heic", sky.Id, context: heic);
matte.Apply(ops => ops.AutoOrient());
matte.Save("sky-matte.png");

Exceptions

ArgumentException

The file has no such item, or it is not an image item.

CorruptDataException

The data breaks the format's rules, including data of another format.

UnsupportedFormatException

The item uses something Egami.Heic does not decode.

ReadItem(string, uint, ReaderOptions?, EgamiContext?)

Reads image item itemId (see Items): an hvc1 item or a grid, converted with its own color into its natural pixel type, as Load converts the primary image; its own clean aperture is cropped, and its own rotation and mirroring are given as the orientation (AutoOrient applies them).

public static Raster ReadItem(string path, uint itemId, ReaderOptions? options = null, EgamiContext? context = null)

Parameters

path string

The file.

itemId uint

The item's id.

options ReaderOptions

The general options; the frame range is ignored.

context EgamiContext

The context, or null for Default. Egami.Heic reads the item whether or not the context registers it.

Returns

Raster

The image. The caller must dispose it.

Examples

// The other images a photo holds: thumbnails, gain maps, depth maps and mattes (portrait, skin, sky).
HeicDetails details = (HeicDetails)sdr.Metadata.FormatDetails!;
HeicItem sky = details.Items.First(i => i.AuxiliaryType == "urn:com:apple:photo:2020:aux:semanticskymatte");
using Raster matte = HeicImage.ReadItem("portrait.heic", sky.Id, context: heic);
matte.Apply(ops => ops.AutoOrient());
matte.Save("sky-matte.png");

Exceptions

ArgumentException

The file has no such item, or it is not an image item.

CorruptDataException

The data breaks the format's rules, including data of another format.

UnsupportedFormatException

The item uses something Egami.Heic does not decode.