Class ReaderOptions
Options for reading. The defaults read everything leniently. Formats with options of their own derive from it, such as JpegReaderOptions.
public record ReaderOptions : IEquatable<ReaderOptions>
- Inheritance
-
ReaderOptions
- Implements
- Derived
- Inherited Members
Examples
// At least 100 × 75 from the stored JPEG, decoded at 1/2, 1/4 or 1/8 scale straight from the DCT.
using Raster preview = Raster.Load("duck.jpg", options: new ReaderOptions { MinimumSize = new Size(100, 75) });
Properties
ConvertColorTo
Gets the encoding to convert the pixels to while loading, or null (the default) to load them as stored. Loading with it gives the same pixels and metadata as loading without it and then calling ConvertColor<TTo>(ColorProfile, ColorTransformOptions?) with the type asked for; loading in the natural type keeps the type when the model stays the same, and otherwise picks the target model's type of the same depth (a CMYK JPEG converted to sRGB loads as Rgb8). Conversion uses Default.
public ColorProfile? ConvertColorTo { get; init; }
Property Value
Examples
// Load straight into sRGB: the same pixels as loading and then calling ConvertColor.
using Raster web = Raster.Load(path, options: new ReaderOptions { ConvertColorTo = ColorProfile.Srgb });
Default
Gets the default options.
public static ReaderOptions Default { get; }
Property Value
Frames
Gets the frames to read. Defaults to all of them. Use ..1 for only the first frame.
public Range Frames { get; init; }
Property Value
Hdr
Gets how to read the HDR rendition of a file that carries a gain map (Ultra HDR, ISO 21496-1 and Apple JPEGs), or null (the default) to read the SDR base image as stored, with the map kept in GainMap. Set, the load gives linear RgbaF16 with 1.0 as SDR white; a file without a gain map loads as it would without it. Region and MinimumSize cannot be combined with it.
public HdrDecode? Hdr { get; init; }
Property Value
Examples
// As stored: the SDR base image, with the gain map in the metadata.
using Raster sdr = Raster.Load("ultrahdr.jpg");
GainMap? map = sdr.Metadata.GainMap; // null for a plain JPEG
// The HDR rendition for a display 4x as bright as SDR white: linear half floats, 1.0 = SDR white.
using Raster<RgbaF16> hdr = Raster.Load<RgbaF16>("ultrahdr.jpg", options: new ReaderOptions { Hdr = new HdrDecode { Headroom = 4 } });
// The same from a raster in hand, at the map's full capacity.
using Raster<RgbaF16> full = map!.Apply(sdr);
MinimumSize
Gets the smallest size the caller needs, or null for full size. The image is decoded reduced by the largest whole factor N that keeps it at least this big: ceil(width / N) by ceil(height / N), each pixel the alpha-weighted average of an N × N block of encoded values (partial blocks at the right and bottom edges average the pixels they have). JPEG keeps its IDCT scaling by 1/2, 1/4 or 1/8 and averages blocks only beyond 1/8. With Region the factor is chosen for the region.
public Size? MinimumSize { get; init; }
Property Value
- Size?
Remarks
Before 1.x 2.2, formats other than JPEG ignored this.
ReadMetadata
Gets whether metadata such as EXIF, ICC, XMP and text is read. Defaults to true.
public bool ReadMetadata { get; init; }
Property Value
Recovery
Gets how damaged data is handled. Defaults to Lenient.
public RecoveryMode Recovery { get; init; }
Property Value
Region
Gets the rectangle to decode, in stored pixels (before EXIF orientation), or null for the whole image. It is clipped to the image and applied before MinimumSize; the result is exactly the clipped rectangle, never widened to a block boundary. For JPEG with a reduced scale the result is the scaled image cropped to the scaled rectangle.
public Rect? Region { get; init; }
Property Value
- Rect?
Remarks
A rectangle that misses the image entirely, or has no area, throws ArgumentOutOfRangeException.