From 154bc6a5c096b4a5ee252ca07fed41c2502a7fc2 Mon Sep 17 00:00:00 2001 From: routersys Date: Sat, 4 Jul 2026 20:37:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=94=E3=82=AF=E3=82=BB=E3=83=AB=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E3=81=B8=E3=83=96=E3=83=A9=E3=82=B7=E5=A1=97=E3=82=8A?= =?UTF-8?q?=E8=AA=AD=E3=81=BF=E6=88=BB=E3=81=97=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/Drawing/PixelBufferManager.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/LuaScript/Drawing/PixelBufferManager.cs b/LuaScript/Drawing/PixelBufferManager.cs index 7eef761..8f6be11 100644 --- a/LuaScript/Drawing/PixelBufferManager.cs +++ b/LuaScript/Drawing/PixelBufferManager.cs @@ -32,7 +32,32 @@ namespace LuaScript { EnsureBitmaps(width, height); RenderToStaging(input, bounds); + return ReadStagingPixels(width, height); + } + public byte[] LoadBrushPixels(ID2D1Brush brush, int width, int height) + { + EnsureBitmaps(width, height); + + var dc = _ctx.DeviceContext; + var rt = (ID2D1RenderTarget)dc; + using var savedTarget = dc.Target; + + dc.Target = _renderTarget; + dc.BeginDraw(); + dc.Clear(null); + rt.Transform = Matrix3x2.CreateTranslation(width / 2f, height / 2f); + rt.FillRectangle(new RawRectF(-width / 2f, -height / 2f, width / 2f, height / 2f), brush); + rt.Transform = Matrix3x2.Identity; + dc.EndDraw(); + dc.Target = savedTarget; + + _stagingBitmap!.CopyFromBitmap(_renderTarget!); + return ReadStagingPixels(width, height); + } + + private unsafe byte[] ReadStagingPixels(int width, int height) + { var mapped = _stagingBitmap!.Map(MapOptions.Read); try {