Function tryConvertUbyteToFloatPlane

Converts one logical ubyte source plane to one equally shaped writable float destination plane.

bool tryConvertUbyteToFloatPlane(
  scope RasterView!(ubyte) source,
  ulong sourcePlaneIndex,
  scope ref WritableRasterView!(float) destination,
  ulong destinationPlaneIndex,
  out UbyteToFloatConversionError error
) nothrow @nogc @safe;

Every successful destination sample is exactly:

cast(float) sourceSample

All 256 ubyte values are exactly representable in IEEE binary32, so this operation has no rounding, clamping, overflow, NaN or infinity policy.

A matching empty source/destination shape succeeds as a no-op.

The destination mapping must be injective.

Source self-aliasing is permitted. Source and destination may share retained backing storage when their actually reachable sample bytes are disjoint.

Actual source/destination sample-byte overlap is rejected before the first destination write.

Returns true on success and false on a semantic request failure.

error is reset to UbyteToFloatConversionError.none on entry. On false it identifies exactly one of:

- invalid source plane; - invalid destination plane; - shape mismatch; - non-injective destination mapping; - actual source/destination sample-byte overlap.

Every validated resident layout is semantically supported.

The operation is allocation-free and retains neither operand.

Example

Example reporting an invalid source plane before conversion.

import raster;
RasterView!ubyte source;
WritableRasterView!float destination;
UbyteToFloatConversionError error;
assert(!tryConvertUbyteToFloatPlane(source, 0, destination, 0, error));
assert(error == UbyteToFloatConversionError.invalidSourcePlane);