Class JxlExtraChannelImage
An extra channel to write with ExtraChannels: its description and its samples, as ReadExtraChannel(string, int, ReaderOptions?, EgamiContext?) gives them back.
public sealed class JxlExtraChannelImage
- Inheritance
-
JxlExtraChannelImage
- Inherited Members
Examples
// A depth map written beside the color, 16 bits, at half the size each way.
using Raster photo = Raster.Load("duck.png");
using Raster<GrayF32> depth = Raster.Create<GrayF32>((photo.Width + 1) / 2, (photo.Height + 1) / 2);
for (int y = 0; y < depth.Height; y++)
{
for (int x = 0; x < depth.Width; x++)
{
depth.Row(y)[x] = new GrayF32((float)y / depth.Height);
}
}
JxlExtraChannel description = new() { Kind = JxlExtraChannelKind.Depth, Name = "depth", BitsPerSample = 16, Subsampling = 1 };
photo.Save("with-depth.jxl", new JxlWriterOptions { Lossless = true, ExtraChannels = [new JxlExtraChannelImage(description, depth)] });
// The channels of a loaded file are not on its raster: read them, and pass them on to keep them.
using Raster loaded = Raster.Load("with-depth.jxl");
JxlDetails details = (JxlDetails)loaded.Metadata.FormatDetails!;
using Raster<GrayF32> again = JxlImage.ReadExtraChannel("with-depth.jxl", 0);
Constructors
JxlExtraChannelImage(JxlExtraChannel, Raster<GrayF32>)
Creates an extra channel to write. The caller keeps the raster and disposes it after the save.
public JxlExtraChannelImage(JxlExtraChannel channel, Raster<GrayF32> samples)
Parameters
channelJxlExtraChannelWhat the channel holds and how it is stored: its kind, name, bits (1 to 24 for integers; 16 with 5 exponent bits or 32 with 8 for floats), subsampling (0 to 3), whether color is premultiplied by it (alpha only) and, for a spot color, its red, green, blue and solidity.
samplesRaster<GrayF32>The samples, at the image size halved Subsampling times each way (rounded up): 0 to 1 for integer channels, which are scaled to their bits and rounded; float channels are stored as given.
Exceptions
- ArgumentNullException
channelorsamplesis null.- ArgumentException
The description is not one JPEG XL can store.
Properties
Channel
Gets the channel's description.
public JxlExtraChannel Channel { get; }
Property Value
Samples
Gets the channel's samples.
public Raster<GrayF32> Samples { get; }