From a44161053b391be994234a7ee98e11d0a621b26b Mon Sep 17 00:00:00 2001 From: ww-rm Date: Thu, 24 Jul 2025 21:27:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dyuv420p=E5=83=8F=E7=B4=A0?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=88=86=E8=BE=A8=E7=8E=87=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E8=A2=AB2=E6=95=B4=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Spine/Exporters/BaseExporter.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Spine/Exporters/BaseExporter.cs b/Spine/Exporters/BaseExporter.cs index 858cf76..7614a92 100644 --- a/Spine/Exporters/BaseExporter.cs +++ b/Spine/Exporters/BaseExporter.cs @@ -31,6 +31,9 @@ namespace Spine.Exporters /// 画布高像素值 public BaseExporter(uint width , uint height) { + // XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错 + width = width >> 1 << 1; + height = height >> 1 << 1; if (width <= 0 || height <= 0) throw new ArgumentException($"Invalid resolution: {width}, {height}"); _renderTexture = new(width, height); @@ -42,6 +45,9 @@ namespace Spine.Exporters /// public BaseExporter(Vector2u resolution) { + // XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错 + resolution.X = resolution.X >> 1 << 1; + resolution.Y = resolution.Y >> 1 << 1; if (resolution.X <= 0 || resolution.Y <= 0) throw new ArgumentException($"Invalid resolution: {resolution}"); _renderTexture = new(resolution.X, resolution.Y); @@ -92,6 +98,9 @@ namespace Spine.Exporters get => _renderTexture.Size; set { + // XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错 + value.X = value.X >> 1 << 1; + value.Y = value.Y >> 1 << 1; if (value.X <= 0 || value.Y <= 0) { _logger.Warn("Omit invalid exporter resolution: {0}", value);