From a66bdba21146d82e35eda94666344d3aa15bc077 Mon Sep 17 00:00:00 2001 From: Dimitri Vranken Date: Thu, 16 Feb 2023 14:35:00 +0100 Subject: [PATCH] Improved SkiaSharp CreateVideoFrame performance --- FFMpegCore.Test/Utilities/BitmapSources.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FFMpegCore.Test/Utilities/BitmapSources.cs b/FFMpegCore.Test/Utilities/BitmapSources.cs index 755f781..8965435 100644 --- a/FFMpegCore.Test/Utilities/BitmapSources.cs +++ b/FFMpegCore.Test/Utilities/BitmapSources.cs @@ -50,10 +50,11 @@ public static Extensions.SkiaSharp.BitmapVideoFrameWrapper CreateVideoFrame(int { 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) => { 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);