Improved SkiaSharp CreateVideoFrame performance

This commit is contained in:
Dimitri Vranken 2023-02-16 14:35:00 +01:00
parent 2458b4ae9c
commit a66bdba211

View file

@ -50,10 +50,11 @@ public static Extensions.SkiaSharp.BitmapVideoFrameWrapper CreateVideoFrame(int
{ {
var bitmap = new SKBitmap(w, h, fmt, SKAlphaType.Opaque); var bitmap = new SKBitmap(w, h, fmt, SKAlphaType.Opaque);
using var bitmapCanvas = new SKCanvas(bitmap);
SetVideoFramePixels(index, w, h, scaleNoise, offset, ((int x, int y, byte red, byte green, byte blue) args) => SetVideoFramePixels(index, w, h, scaleNoise, offset, ((int x, int y, byte red, byte green, byte blue) args) =>
{ {
var color = new SKColor(args.red, args.blue, args.green); var color = new SKColor(args.red, args.blue, args.green);
bitmap.SetPixel(args.x, args.y, color); bitmapCanvas.DrawPoint(args.x, args.y, color);
}); });
return new Extensions.SkiaSharp.BitmapVideoFrameWrapper(bitmap); return new Extensions.SkiaSharp.BitmapVideoFrameWrapper(bitmap);