Aspose.PSD for .NET 23.9 - 发行说明

关键 摘要 类别
PSDNET-1638 实现为新调整图层创建蒙版 功能
PSDNET-1654 添加对剪切图层作为组合混合选项的支持 功能
PSDNET-1194 具有16位颜色模式的PSD文件不适用于调整图层的蒙版 故障
PSDNET-1235 文本图层中括号的渲染不正确 故障
PSDNET-1559 无法更新文本图层中的样式 故障
PSDNET-1583 使用CMYK导出PSD文件后,导出的PSD文件中的颜色破损 故障
PSDNET-1619 特定PSB文件抛出异常“矩形没有共同的处理区域” 故障
PSDNET-1648 图像加载失败。OverflowException:算术运算导致溢出 故障

公共 API 更改

已添加的 API:

  • P:Aspose.PSD.FileFormats.Psd.Layers.Layer.BlendClippedElements
  • T:Aspose.PSD.CustomFontHandler.CustomFontData
  • M:Aspose.PSD.CustomFontHandler.CustomFontData.#ctor(System.String,System.Byte[])
  • P:Aspose.PSD.CustomFontHandler.CustomFontData.FontName
  • P:Aspose.PSD.CustomFontHandler.CustomFontData.FontData
  • P:Aspose.PSD.FontSettings.GetSystemAlternativeFont
  • P:Aspose.PSD.Graphics.PaintableImageOptions
  • P:Aspose.PSD.Image.UsePalette
  • M:Aspose.PSD.Region.Equals(System.Object)
  • M:Aspose.PSD.Region.GetHashCode
  • P:Aspose.PSD.StringFormat.CustomCharIdent
  • M:Aspose.PSD.StringFormat.Equals(System.Object)
  • M:Aspose.PSD.StringFormat.GetHashCode
  • F:Aspose.PSD.StringFormatFlags.ExactAlignment

已移除的 API:

使用示例:

PSDNET-1638. 实现为新调整图层创建蒙版

string srcFile = "zendeya_BW.psd";
string dstFile = "zendeya_BW_out.psd";

using (var im = (PsdImage)Image.Load(srcFile))
{
    im.AddBlackWhiteAdjustmentLayer();

    im.Save(dstFile);
}

using (var im = (PsdImage)Image.Load(dstFile))
{
    Layer layer = im.Layers[1];

    AssertAreEqual((ushort)5, layer.ChannelsCount);
    AssertAreEqual((short)-2, layer.ChannelInformation[4].ChannelID);
}

void AssertAreEqual(object expected, object actual, string message = null)
{
    if (!object.Equals(expected, actual))
    {
        throw new Exception(message ?? "对象不相等。");
    }
}

PSDNET-1654. 添加对剪切图层作为组合混合选项的支持

string sourceFile = "example_source.psd";
string outputPsd = "example_output.psd";
string outputPng = "example_output.png";

using (var image = (PsdImage)Image.Load(sourceFile))
{
    image.Layers[1].BlendClippedElements = false;
    image.Save(outputPsd);
    image.Save(outputPng, new PngOptions());
}

PSDNET-1194. 具有16位颜色模式的PSD文件不适用于调整图层的蒙版

string sourceFile = "source.psd";
string outputPng = "current.png";

using (var image = (PsdImage)Image.Load(sourceFile))
{
    image.Save(outputPng, new PngOptions());
}

PSDNET-1235. 文本图层中括号的渲染不正确

string file = "file1.psd";
string output = "output_1235.png";

using (var psdImage = (PsdImage)Image.Load(file))
{
    foreach (var layer in psdImage.Layers)
    if (layer is TextLayer textLayer)
    textLayer.TextData.UpdateLayerData();

    var imageOptions = new PsdOptions(psdImage);
    psdImage.Save(output, imageOptions);
}

PSDNET-1559. 无法更新文本图层中的样式

string sourceFile = "Example_FontSize.psd";
string outputFile = "output_Example_FontSize.psd";

using (var psdImage = (PsdImage)Image.Load(sourceFile, new PsdLoadOptions() { LoadEffectsResource = true }))
{
    var l1 = (TextLayer)psdImage.Layers[4];
    var l2 = (TextLayer)psdImage.Layers[5];

    var textItems1 = l1.TextData.ProducePortions(new string[] { "text1", "text2" }, l1.TextData.Items[0].Style, l1.TextData.Items[0].Paragraph);

    l1.TextData.RemovePortion(0);
    foreach (var item in textItems1)
    {
        l1.TextData.AddPortion(item);
    }

    var textItems2 = l2.TextData.ProducePortions(new string[] { "text layer 1", "text layer 22" }, l2.TextData.Items[0].Style, l2.TextData.Items[0].Paragraph);

    foreach (var item in textItems2)
    {
        l2.TextData.AddPortion(item);
    }

    l1.TextData.UpdateLayerData();
    l2.TextData.UpdateLayerData();

    psdImage.Save(outputFile);
}

PSDNET-1583. 使用CMYK导出PSD文件后,导出的PSD文件中的颜色破损

string sourceFile = "canyon.psd";
string outputFilePng = "output_canyon.png";

using (var outputStream = new MemoryStream())
{
    using (var psdImage = (PsdImage)Image.Load(sourceFile))
    {
        psdImage.Save(outputStream);
    }

    outputStream.Position = 0;
    using (var psdImage = (PsdImage)Image.Load(outputStream))
    {
        psdImage.Save(outputFilePng, new PngOptions());
    }
}

PSDNET-1619. 特定PSB文件抛出异常“矩形没有共同的处理区域”

var input = "1619_src.psb";
var output = "1619_output.png";
using (PsdImage img = (PsdImage)Image.Load(input, new PsdLoadOptions() { LoadEffectsResource = true }))
{
    img.Save(output,
    new PngOptions() { CompressionLevel = 9, ColorType = PngColorType.TruecolorWithAlpha });
}

PSDNET-1648. 图像加载失败。OverflowException: 算术运算导致溢出

string sourceFile = "9baa6962-f409-41ee-88da-418ea87bb56f_test_2.psd";

using (PsdImage im = (PsdImage)PsdImage.Load(sourceFile))
{
    Layer layer = im.Layers[28];
    GrdmResource grdmResource = (GrdmResource)layer.Resources[0];

    AssertAreEqual("自定", grdmResource.GradientName);
}

void AssertAreEqual(object expected, object actual, string message = null)
{
    if (!object.Equals(expected, actual))
    {
        throw new Exception(message ?? "对象不相等。");
    }
}