修复yuv420p像素格式分辨率必须被2整除的问题
This commit is contained in:
@@ -31,6 +31,9 @@ namespace Spine.Exporters
|
|||||||
/// <param name="height">画布高像素值</param>
|
/// <param name="height">画布高像素值</param>
|
||||||
public BaseExporter(uint width , uint height)
|
public BaseExporter(uint width , uint height)
|
||||||
{
|
{
|
||||||
|
// XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错
|
||||||
|
width = width >> 1 << 1;
|
||||||
|
height = height >> 1 << 1;
|
||||||
if (width <= 0 || height <= 0)
|
if (width <= 0 || height <= 0)
|
||||||
throw new ArgumentException($"Invalid resolution: {width}, {height}");
|
throw new ArgumentException($"Invalid resolution: {width}, {height}");
|
||||||
_renderTexture = new(width, height);
|
_renderTexture = new(width, height);
|
||||||
@@ -42,6 +45,9 @@ namespace Spine.Exporters
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BaseExporter(Vector2u resolution)
|
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)
|
if (resolution.X <= 0 || resolution.Y <= 0)
|
||||||
throw new ArgumentException($"Invalid resolution: {resolution}");
|
throw new ArgumentException($"Invalid resolution: {resolution}");
|
||||||
_renderTexture = new(resolution.X, resolution.Y);
|
_renderTexture = new(resolution.X, resolution.Y);
|
||||||
@@ -92,6 +98,9 @@ namespace Spine.Exporters
|
|||||||
get => _renderTexture.Size;
|
get => _renderTexture.Size;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
// XXX: 强制变成 2 的倍数, 防止像是 yuv420p 这种像素格式报错
|
||||||
|
value.X = value.X >> 1 << 1;
|
||||||
|
value.Y = value.Y >> 1 << 1;
|
||||||
if (value.X <= 0 || value.Y <= 0)
|
if (value.X <= 0 || value.Y <= 0)
|
||||||
{
|
{
|
||||||
_logger.Warn("Omit invalid exporter resolution: {0}", value);
|
_logger.Warn("Omit invalid exporter resolution: {0}", value);
|
||||||
|
|||||||
Reference in New Issue
Block a user