Table of Contents

Class ExrImage

Namespace
Egami.Formats.Exr
Assembly
Egami.dll

Reads single OpenEXR channels that are not color, such as depth, object IDs or render passes.

public static class ExrImage
Inheritance
ExrImage
Inherited Members

Examples

// The first part's RGBA channels as linear light, 1.0 reference white; other layers by name.
using Raster<RgbaF32> beauty = Raster.Load<RgbaF32>("render.exr");
var details = (ExrDetails)beauty.Metadata.FormatDetails!;
IReadOnlyList<string> layers = details.Parts[details.Part].Layers;       // "diffuse", "specular"
using Raster<RgbaF32> diffuse = Raster.Load<RgbaF32>("render.exr", options: new ExrReaderOptions { Layer = "diffuse" });

// Any one channel, such as depth or an object id, as 32-bit float.
using Raster<GrayF32> depth = ExrImage.ReadChannel("aov.exr", "Z");

Methods

ReadChannel(Stream, string, ExrReaderOptions?, EgamiContext?)

public static Raster<GrayF32> ReadChannel(Stream stream, string channel, ExrReaderOptions? options = null, EgamiContext? context = null)

Parameters

stream Stream

The file's data, from its start.

channel string

The channel's full name.

options ExrReaderOptions

Which part to read, and the general options; the layer and window are ignored.

context EgamiContext

The context, or null for Default.

Returns

Raster<GrayF32>

The channel's samples.

Examples

// The first part's RGBA channels as linear light, 1.0 reference white; other layers by name.
using Raster<RgbaF32> beauty = Raster.Load<RgbaF32>("render.exr");
var details = (ExrDetails)beauty.Metadata.FormatDetails!;
IReadOnlyList<string> layers = details.Parts[details.Part].Layers;       // "diffuse", "specular"
using Raster<RgbaF32> diffuse = Raster.Load<RgbaF32>("render.exr", options: new ExrReaderOptions { Layer = "diffuse" });

// Any one channel, such as depth or an object id, as 32-bit float.
using Raster<GrayF32> depth = ExrImage.ReadChannel("aov.exr", "Z");

Exceptions

ArgumentException

The part has no such channel.

ReadChannel(string, string, ExrReaderOptions?, EgamiContext?)

Reads one channel, such as "Z" or "diffuse.R", into a gray raster at the channel's stored resolution (smaller than the data window when the channel is subsampled). Half and uint samples convert to float; uint values above 2^24 lose their lowest bits.

public static Raster<GrayF32> ReadChannel(string path, string channel, ExrReaderOptions? options = null, EgamiContext? context = null)

Parameters

path string

The file.

channel string

The channel's full name.

options ExrReaderOptions

Which part to read, and the general options; the layer and window are ignored.

context EgamiContext

The context, or null for Default.

Returns

Raster<GrayF32>

The channel's samples.

Examples

// The first part's RGBA channels as linear light, 1.0 reference white; other layers by name.
using Raster<RgbaF32> beauty = Raster.Load<RgbaF32>("render.exr");
var details = (ExrDetails)beauty.Metadata.FormatDetails!;
IReadOnlyList<string> layers = details.Parts[details.Part].Layers;       // "diffuse", "specular"
using Raster<RgbaF32> diffuse = Raster.Load<RgbaF32>("render.exr", options: new ExrReaderOptions { Layer = "diffuse" });

// Any one channel, such as depth or an object id, as 32-bit float.
using Raster<GrayF32> depth = ExrImage.ReadChannel("aov.exr", "Z");

Exceptions

ArgumentException

The part has no such channel.