BitmapDataFactoryCreateCalculated(Size, FuncInt32, Int32, Color32, Action) Method
Creates a read-only bitmap data with no actual underlying buffer, whose pixel values are calculated on demand using the specified delegate.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.1
public static IReadableBitmapData CreateCalculated(
Size size,
Func<int, int, Color32> getColor,
Action? disposeCallback = null
)
Public Shared Function CreateCalculated (
size As Size,
getColor As Func(Of Integer, Integer, Color32),
Optional disposeCallback As Action = Nothing
) As IReadableBitmapData
public:
static IReadableBitmapData^ CreateCalculated(
Size size,
Func<int, int, Color32>^ getColor,
Action^ disposeCallback = nullptr
)
static member CreateCalculated :
size : Size *
getColor : Func<int, int, Color32> *
?disposeCallback : Action
(* Defaults:
let _disposeCallback = defaultArg disposeCallback null
*)
-> IReadableBitmapData
- size Size
- The size, in pixels, of the bitmap data to create.
- getColor FuncInt32, Int32, Color32
- A delegate that can get the color of a pixel as a Color32 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: .
IReadableBitmapDataAn
IReadableBitmapData instance, whose pixel values are calculated on demand using the specified delegate.
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.
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.