From 71f12b7597bccdccf67ee47727d8b08e3e827cdb Mon Sep 17 00:00:00 2001 From: jasper Date: Tue, 25 Jun 2024 22:14:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建空对象,避免构建SKBitmap调用TryAllocPixels 申请无用的内存 --- CPF.Skia/SkiaDrawingContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CPF.Skia/SkiaDrawingContext.cs b/CPF.Skia/SkiaDrawingContext.cs index 1541bca..1fa4e87 100644 --- a/CPF.Skia/SkiaDrawingContext.cs +++ b/CPF.Skia/SkiaDrawingContext.cs @@ -126,8 +126,8 @@ namespace CPF.Skia BITMAP BITMAP = new BITMAP(); UnmanagedMethods.GetObject(hbitmap, Marshal.SizeOf(typeof(BITMAP)), BITMAP); - var bitmap = new SKBitmap(BITMAP.bmWidth, BITMAP.bmHeight); - bitmap.SetPixels(BITMAP.bmBits); + var bitmap = new SKBitmap(); + bitmap.InstallPixels(new SKImageInfo(BITMAP.bmWidth, BITMAP.bmHeight, SKImageInfo.PlatformColorType), BITMAP.bmBits, BITMAP.bmWidthBytes); this.bitmap = bitmap; canvas = new SKCanvas(this.bitmap);