PeachImage
PeachImage.DecoderOptions
DecoderOptions.TargetPixelFormat Property
The pixel format the caller wants the decoded Image to use, analogous to stb_image’s
req_comp. When null, the decoder produces whatever format is most natural
for the source data.
public System.Nullable<PeachImage.PixelFormat> TargetPixelFormat { get; init; }
Property Value
Remarks
Every codec’s Decode reads this property directly off the base-typed DecoderOptions
parameter it’s given — never by downcasting to its own concrete options subtype first. (A codec may
separately downcast to its own subtype to read format-specific extras, like JPEG’s FastUpsampling,
but that downcast only gates those extras — when it fails because a different concrete type was passed,
the codec falls back to that format’s defaults for its own extras and keeps honoring
TargetPixelFormat regardless.) Concretely: new DecoderOptions { TargetPixelFormat =
PixelFormat.Rgba32 } passed to Load(Stream, DecoderOptions) is honored no
matter which format the stream turns out to be — a plain JpegDecoderOptions,
PngDecoderOptions, or the base DecoderOptions all
behave identically as far as this property is concerned. This is what makes it safe to set
TargetPixelFormat once for a format-agnostic decode without picking a per-format subtype
up front.