Function tryTransformAllocated
Allocates a new compact one-plane raster and applies one compile-time same-type point transform into it.
RasterAllocatedTransformResult!T tryTransformAllocated(alias transform, T)(
scope RasterView!T source,
size_t sourcePlaneIndex
) @safe;
Allocation is explicit in both the function name and result type.
The selected source plane is the semantic input. The successful output:
- has the same sample type T; - has width/height equal to source; - has resident origin (0,0); - contains exactly one logical plane; - uses newly owned compact row-major storage; - is writable through the ordinary retained writable-certification path; - does not alias source storage.
Matching zero-area source geometry succeeds without pixel allocation. A metadata-only retained one-plane owner is produced and transform is not invoked.
The operation is deliberately a convenience/materialization layer:
validate selected source plane -> allocate compact retained destination -> obtain writable destination view -> transformInto!transform(...)
It contains no second transform kernel.
transformInto() remains the performance-oriented primitive when callers already own or want to reuse destination storage.
The transform alias must satisfy the same compile-time contract as transformInto():
@safe pure nothrow @nogc T -> T
Allocation and retained-owner construction are fallible. Error-level failure while creating the retained owner remains governed by the backing layer's allocation contract.
Example
Example using the allocating convenience through UFCS.
import raster;
alias plusOne =
(float value)
@safe pure nothrow @nogc
=> value + 1.0f;
RasterView!float source;
const result =
source .tryTransformAllocated!plusOne(
0
);
assert(!result .ok);
assert(
result .error
== RasterAllocatedTransformError .invalidSourcePlane
);