BitmapDataFactoryCreateCalculated(Size, FuncInt32, Int32, ColorF, Action) Method

Creates a read-only bitmap data with no actual underlying buffer, whose pixel values are calculated on demand using the specified delegate.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.1
C#
public static IReadableBitmapData CreateCalculated(
	Size size,
	Func<int, int, ColorF> getColor,
	Action? disposeCallback = null
)

Parameters

size  Size
The size, in pixels, of the bitmap data to create.
getColor  FuncInt32, Int32, ColorF
A delegate that can get the color of a pixel as a ColorF instance. Its input parameters are the pixel coordinates (x, y).
disposeCallback  Action  (Optional)
A delegate to be called when the returned IReadableBitmapData is disposed or finalized. This parameter is optional.
Default value: .

Return Value

IReadableBitmapData
An IReadableBitmapData instance, whose pixel values are calculated on demand using the specified delegate.

Remarks

The returned bitmap data does not store pixel values; instead, it calculates them dynamically using the provided function. This can be useful for generating procedural images or for scenarios where storing the entire bitmap in memory is unnecessary.

  Note

Though the returned bitmap does not allocate an internal buffer and calculates every pixel dynamically when they are accessed, operations on the result that return a new bitmap data (e.g. Clone, Resize, ToGrayscale, etc.) end up allocating a pixel buffer.

See Also