Function convertRasterInto

Converts one selected logical source plane into an equally shaped writable destination plane under one explicit conversion policy.

bool convertRasterInto(To, RasterConversionPolicy Policy = RasterConversionPolicy.exact, From)(
  scope RasterView!From source,
  size_t sourcePlaneIndex,
  scope ref WritableRasterView!To destination,
  size_t destinationPlaneIndex,
  out RasterConversionError error
) nothrow @nogc @safe
if (Policy == RasterConversionPolicy.exact && isUniversallyExactRasterConversion!(From, To));

The first v0.2 production policy is RasterConversionPolicy.exact.

Ordinary form:

convertRasterInto!( float, RasterConversionPolicy.exact )( source, sourcePlaneIndex, destination, destinationPlaneIndex, error );

UFCS form:

source.convertRasterInto!( float, RasterConversionPolicy.exact )( sourcePlaneIndex, destination, destinationPlaneIndex, error );

Because exact is currently the only promoted policy it is also the template

default

source.convertRasterInto!float(...);

Exact-policy type legality is compile-time. Unsupported From -> To pairs do not instantiate this API.

Structural semantics:

- source and destination plane indices must be valid; - shapes must match; - matching empty shapes succeed as a no-op; - destination mapping must be injective; - actual source/destination sample-byte overlap is rejected; - every structural failure is resolved before the first destination write; - every validated resident signed affine layout is semantically supported; - source self-aliasing is permitted; - no allocation, ownership transfer or scheduling occurs.

On entry error is reset to RasterConversionError.none. On false, destination content is unchanged and error identifies the structural failure.

Example

Example compiling the default exact-policy UFCS surface.

import raster;

RasterView!ubyte source;
WritableRasterView!float destination;
RasterConversionError error;

assert(
    !source.convertRasterInto!float(
        0,
        destination,
        0,
        error
    )
);

assert(
    error
    == RasterConversionError.invalidSourcePlane
);