Class AvifImage
Reads the images an AVIF file holds besides the one Load gives: thumbnails, depth maps and other auxiliary images.
public static class AvifImage
- Inheritance
-
AvifImage
- Inherited Members
Examples
// Every item of the file, with what it is to the image Load gives: alpha, thumbnails, depth maps, grid cells, metadata.
using Raster image = Raster.Load("duck.avif");
IReadOnlyList<AvifItem> items = ((AvifDetails)image.Metadata.FormatDetails!).Items;
AvifItem primary = items.First(i => i.Role == AvifItemRole.Primary);
// Any image item decodes on its own, with its own color, such as a depth map or a thumbnail.
using Raster item = AvifImage.ReadItem("duck.avif", primary.Id);
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
streamStreamThe file's data, from its start.
itemIduintThe item's id.
optionsReaderOptionsThe general options (FilmGrain applies); the frame range is ignored.
contextEgamiContext
Returns
- Raster
The image. The caller must dispose it.
Examples
// Every item of the file, with what it is to the image Load gives: alpha, thumbnails, depth maps, grid cells, metadata.
using Raster image = Raster.Load("duck.avif");
IReadOnlyList<AvifItem> items = ((AvifDetails)image.Metadata.FormatDetails!).Items;
AvifItem primary = items.First(i => i.Role == AvifItemRole.Primary);
// Any image item decodes on its own, with its own color, such as a depth map or a thumbnail.
using Raster item = AvifImage.ReadItem("duck.avif", primary.Id);
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.
ReadItem(string, uint, ReaderOptions?, EgamiContext?)
Reads image item itemId (see Items): an av01 item or a grid, converted with its
own color into its natural pixel type, as Load converts the primary image; its own clean aperture cropped, and its own
rotation and mirroring (irot, imir) given as the orientation, which AutoOrient applies.
public static Raster ReadItem(string path, uint itemId, ReaderOptions? options = null, EgamiContext? context = null)
Parameters
pathstringThe file.
itemIduintThe item's id.
optionsReaderOptionsThe general options (FilmGrain applies); the frame range is ignored.
contextEgamiContext
Returns
- Raster
The image. The caller must dispose it.
Examples
// Every item of the file, with what it is to the image Load gives: alpha, thumbnails, depth maps, grid cells, metadata.
using Raster image = Raster.Load("duck.avif");
IReadOnlyList<AvifItem> items = ((AvifDetails)image.Metadata.FormatDetails!).Items;
AvifItem primary = items.First(i => i.Role == AvifItemRole.Primary);
// Any image item decodes on its own, with its own color, such as a depth map or a thumbnail.
using Raster item = AvifImage.ReadItem("duck.avif", primary.Id);
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.