Function RasterView.trySample

Attempts to read one logical sample.

bool trySample(
  size_t band,
  size_t x,
  size_t y,
  out T value
) const nothrow @nogc @trusted;

Coordinates x and y are relative to this view.

Internally they resolve into resident descriptor-space coordinates. They are never interpreted as global LogicalImage coordinates.

Returns false when the band or coordinates are outside the view.

On failure value is reset to T.init.

This accessor returns a value copy and therefore grants no write capability to the underlying raster storage.

This is primarily a correctness/control-plane accessor. Performance kernels will later use separately validated internal adapters rather than repeatedly performing these bounds checks.

Example

Example reading from an empty view without exposing a pointer.

import raster;
RasterView!ubyte view;
ubyte value = 99;
assert(!view.trySample(0, 0, 0, value));
assert(value == ubyte.init);
}