From 214b84c71d14f9a6b9746e2a1a05087cde97b8b2 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 9 Feb 2025 20:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`SaveAsImage`=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=9B=BE=E7=89=87=E6=97=B6=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=80=8F=E6=98=8E=E5=BA=A6=E7=9A=84=E9=97=AE=E9=A2=98=20(#337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Examples/Example50_Scatter.cs | 4 ++-- Runtime/Internal/Utilities/ChartHelper.cs | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5d4450db..efd4a126 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -79,6 +79,7 @@ slug: /changelog ## master +* (2025.02.09) 修复`SaveAsImage`保存图片时不支持透明度的问题 (#337) * (2025.02.05) 增加`GraphChart`可单独设置`data`样式的支持 * (2025.02.05) 重构`SerieSymbol`的`sizeFunction`参数 * (2025.01.23) 修复`Treemap`的`Label`不显示的问题 diff --git a/Examples/Example50_Scatter.cs b/Examples/Example50_Scatter.cs index 80f8f967..63d377fd 100644 --- a/Examples/Example50_Scatter.cs +++ b/Examples/Example50_Scatter.cs @@ -21,9 +21,9 @@ namespace XCharts.Example } } - float SymbolSize(List data) + float SymbolSize(float defaultSize, SerieData serieData) { - return (float) (Math.Sqrt(data[2]) / 6e2); + return defaultSize; } } } \ No newline at end of file diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index 6c1b31bf..46b9238a 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -1059,12 +1059,12 @@ namespace XCharts.Runtime { var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera; var pos = RectTransformUtility.WorldToScreenPoint(cam, rectTransform.position); - var width = rectTransform.rect.width * canvas.scaleFactor; - var height = rectTransform.rect.height * canvas.scaleFactor; + var width = (int)(rectTransform.rect.width * canvas.scaleFactor); + var height = (int)(rectTransform.rect.height * canvas.scaleFactor); var posX = pos.x + rectTransform.rect.xMin * canvas.scaleFactor; var posY = pos.y + rectTransform.rect.yMin * canvas.scaleFactor; var rect = new Rect(posX, posY, width, height); - var tex = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false); + var tex = new Texture2D(width, height, TextureFormat.ARGB32, false); tex.ReadPixels(rect, 0, 0); tex.Apply(); byte[] bytes;