CaptureOptions
Namespace: BlazorNative.Core
The knobs the app sets so it controls the captured file's size. The
system camera app writes a full-resolution JPEG (often 4000×3000+, several MB);
the shell then downsamples it to CaptureOptions.MaxDimension on the long edge and
re-encodes at CaptureOptions.Quality before returning the path, so the file — and
the bitmap BnImage decodes from it — is bounded. A 0CaptureOptions.MaxDimension means "keep full resolution" (explicit opt-in to the
big file). Defaults: a ~2048 px long edge and JPEG quality 85 (a couple hundred
KB for fidelity a phone screen cannot out-resolve).
NOTE (issue #178): the EXPLICIT parameterless constructor below is
load-bearing. For a record struct whose primary-constructor parameters
are all optional, new CaptureOptions() binds to the implicit field-zeroing
struct constructor — NOT the primary constructor — so WITHOUT this explicit ctor
even new CaptureOptions() would yield MaxDimension=0, Quality=0
rather than the documented 2048/85. The explicit ctor chains to the primary
constructor so new CaptureOptions() genuinely carries the defaults.
default(CaptureOptions) still zero-initialises (the language guarantees a
zeroing parameterless value for every struct and no ctor can suppress it); a
zeroed value is treated as UNSET at the shell boundary, where a 0 quality maps to
the default rather than the worst-possible encode.
public readonly record struct CaptureOptions
Inheritance Object → ValueType → CaptureOptions
Implements IEquatable<CaptureOptions>
Attributes IsReadOnlyAttribute
Properties
MaxDimension
Long-edge cap in pixels for the downscale; 0 keeps full resolution. Default 2048.
public int MaxDimension { get; init; }
Property Value
Quality
JPEG quality 1–100 for the re-encode. Default 85.
public int Quality { get; init; }
Property Value
Constructors
CaptureOptions(Int32, Int32)
The knobs the app sets so it controls the captured file's size. The
system camera app writes a full-resolution JPEG (often 4000×3000+, several MB);
the shell then downsamples it to CaptureOptions.MaxDimension on the long edge and
re-encodes at CaptureOptions.Quality before returning the path, so the file — and
the bitmap BnImage decodes from it — is bounded. A 0CaptureOptions.MaxDimension means "keep full resolution" (explicit opt-in to the
big file). Defaults: a ~2048 px long edge and JPEG quality 85 (a couple hundred
KB for fidelity a phone screen cannot out-resolve).
NOTE (issue #178): the EXPLICIT parameterless constructor below is
load-bearing. For a record struct whose primary-constructor parameters
are all optional, new CaptureOptions() binds to the implicit field-zeroing
struct constructor — NOT the primary constructor — so WITHOUT this explicit ctor
even new CaptureOptions() would yield MaxDimension=0, Quality=0
rather than the documented 2048/85. The explicit ctor chains to the primary
constructor so new CaptureOptions() genuinely carries the defaults.
default(CaptureOptions) still zero-initialises (the language guarantees a
zeroing parameterless value for every struct and no ctor can suppress it); a
zeroed value is treated as UNSET at the shell boundary, where a 0 quality maps to
the default rather than the worst-possible encode.
public CaptureOptions(int MaxDimension = 2048, int Quality = 85)
Parameters
MaxDimension Int32
Long-edge cap in pixels for the downscale; 0 keeps full
resolution. Default 2048.
Quality Int32
JPEG quality 1–100 for the re-encode. Default 85.
CaptureOptions()
The documented defaults (2048 px long edge, JPEG quality 85). Present
because a record struct's primary-constructor defaults do NOT apply to
new CaptureOptions() — that binds to the field-zeroing struct ctor — so
this explicit ctor chains to the primary constructor to make them real (#178).
The literals must match the primary-constructor defaults above.
public CaptureOptions()