From a139326c39d60011e7478ef1037ed3d7b9a361de Mon Sep 17 00:00:00 2001 From: routersys Date: Wed, 1 Jul 2026 13:49:24 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E6=88=90=E6=8F=8F=E7=94=BB=E3=81=AEOp?= =?UTF-8?q?acity=E5=87=BA=E5=8A=9B=E3=82=92=E3=82=AD=E3=83=A3=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=81=97=E3=81=A6=E6=AF=8E=E6=8F=8F=E7=94=BB?= =?UTF-8?q?=E3=81=AECOM=E7=A2=BA=E4=BF=9D=E3=82=92=E7=84=A1=E3=81=8F?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/DrawCompositor.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/LuaScript/DrawCompositor.cs b/LuaScript/DrawCompositor.cs index 78af3dd..d32427c 100644 --- a/LuaScript/DrawCompositor.cs +++ b/LuaScript/DrawCompositor.cs @@ -19,6 +19,7 @@ namespace LuaScript private ID2D1Bitmap1? _target; private AffineTransform2D? _placement; private Opacity? _opacityEffect; + private ID2D1Image? _opacityOutput; private int _sourceWidth; private int _sourceHeight; private int _targetWidth; @@ -123,18 +124,10 @@ namespace LuaScript var interp = ToImageInterpolation(interpolation); _opacityEffect!.Value = opacity; - var image = _opacityEffect.Output; - try - { - if (blend.IsCompositionEffect()) - _ctx.DeviceContext.DrawImage(image, interpolationMode: interp, compositeMode: blend.ToD2DCompositionMode()); - else - _ctx.DeviceContext.BlendImage(image, blend.ToD2DBlendMode(), null, null, interp); - } - finally - { - image.Dispose(); - } + if (blend.IsCompositionEffect()) + _ctx.DeviceContext.DrawImage(_opacityOutput!, interpolationMode: interp, compositeMode: blend.ToD2DCompositionMode()); + else + _ctx.DeviceContext.BlendImage(_opacityOutput!, blend.ToD2DBlendMode(), null, null, interp); } private static InterpolationMode ToImageInterpolation(BitmapInterpolationMode mode) => @@ -150,7 +143,11 @@ namespace LuaScript _sourceWidth = width; _sourceHeight = height; - _opacityEffect ??= new Opacity(_ctx.DeviceContext); + if (_opacityEffect is null) + { + _opacityEffect = new Opacity(_ctx.DeviceContext); + _opacityOutput = _opacityEffect.Output; + } _opacityEffect.SetInput(0, _source, true); } @@ -174,10 +171,12 @@ namespace LuaScript public void Dispose() { _placement?.Dispose(); + _opacityOutput?.Dispose(); _opacityEffect?.Dispose(); _source?.Dispose(); _target?.Dispose(); _placement = null; + _opacityOutput = null; _opacityEffect = null; _source = null; _target = null;