Aspose.PSD for Java 20.3 - 发行说明

关键 摘要 类别
PSDJAVA-133 将Adobe Illustrator文件转换为PDF 功能
PSDJAVA-134 添加能够在一个文本层中呈现不同样式的功能 功能
PSDJAVA-135 支持黑白调整图层 功能
PSDJAVA-137 支持将AI格式(版本8)导出为其他格式 功能
PSDJAVA-138 支持按通行通过混合模式处理(仅用于图层组) 功能
PSDJAVA-136 加载带有空Unicode Alpha Names资源的图像失败异常 错误
PSDJAVA-139 更改图层组可见性后输出不正确 错误
PSDJAVA-140 加载PSD图像时发生异常:颜色部分(DropShadow资源)必须包含RGB的3个颜色分量或CMYK的4个颜色分量 错误
PSDJAVA-141 如果使用简化版本的构造函数尝试在新创建的图层上绘制,则会引发异常 错误

公共 API 更改

已添加的 API:

  • M:com.aspose.psd.fileformats.psd.PsdImage.addBlackWhiteAdjustmentLayer
  • M:com.aspose.psd.fileformats.psd.PsdImage.addExposureAdjustmentLayer(float)
  • M:com.aspose.psd.fileformats.psd.PsdImage.addExposureAdjustmentLayer(float,float)
  • T:com.aspose.psd.fileformats.psd.PsdVersion
  • F:com.aspose.psd.fileformats.psd.PsdVersion.Psb
  • F:com.aspose.psd.fileformats.psd.PsdVersion.Psd
  • F:com.aspose.psd.fileformats.psd.layers.BlendMode.Absent
  • M:com.aspose.psd.fileformats.psd.layers.ChannelInformation.#ctor(short,byte[],byte[])
  • M:com.aspose.psd.fileformats.psd.layers.Layer.#ctor(com.aspose.psd.RasterImage)
  • M:com.aspose.psd.fileformats.psd.layers.Layer.#ctor(com.aspose.psd.internal.ij.k,com.aspose.psd.IColorPalette)
  • M:com.aspose.psd.fileformats.psd.layers.LayerGroup.getBlendModeKey
  • M:com.aspose.psd.fileformats.psd.layers.LayerGroup.setBlendModeKey(long)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesContinuousManager.getChannelsCount
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesContinuousManager.isChannelUsed(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesDiscreteManager.#ctor(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesDiscreteManager.getChannelsCount
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesDiscreteManager.isChannelUsed(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesManager.getChannelsCount
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.CurvesManager.isChannelUsed(int)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.LayerSectionResource.setBlendModeKey(long)
  • M:com.aspose.psd.fileformats.psd.layers.text.IText.producePortions(java.lang.String[],com.aspose.psd.fileformats.psd.layers.text.ITextStyle,com.aspose.psd.fileformats.psd.layers.text.ITextParagraph)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getBaselineShift
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getFauxBold
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getFauxItalic
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getFontBaseline
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getFontCaps
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getStrikethrough
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.getUnderline
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setBaselineShift(double)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setFauxBold(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setFauxItalic(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setFontBaseline(int)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setFontCaps(int)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setLeading(double)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setStrikethrough(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setUnderline(boolean)
  • T:com.aspose.psd.fileformats.psd.layers.text.rendering.FontBaseline
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontBaseline.None
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontBaseline.Subscript
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontBaseline.Superscript
  • T:com.aspose.psd.fileformats.psd.layers.text.rendering.FontCaps
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontCaps.AllCaps
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontCaps.None
  • F:com.aspose.psd.fileformats.psd.layers.text.rendering.FontCaps.SmallCaps
  • M:com.aspose.psd.sources.StreamSource.#ctor(java.io.OutputStream)
  • M:com.aspose.psd.sources.StreamSource.#ctor(java.io.OutputStream,boolean)

已移除的 API:

  • M:com.aspose.psd.fileformats.psd.layers.Layer.setVisibleInGroup(boolean)
  • M:com.aspose.psd.fileformats.psd.layers.layerresources.LayerSectionResource.setBlendModeKey(java.lang.String)
  • M:com.aspose.psd.fileformats.psd.layers.text.ITextStyle.setLeading(int)

使用示例:

PSDJAVA-133. 将Adobe Illustrator文件转换为PDF

 String inFile = "rect2_color.ai";

String outFile = "rect2_color.ai_output.pdf";

AiImage aiImage = (AiImage)Image.load(inFile);

try

{

    aiImage.save(outFile, new PdfOptions());

}

finally

{

    aiImage.dispose();

}

PSDJAVA-134. 添加能够在一个文本层中呈现不同样式的功能

 String inFilePath = "text212.psd";

String outFilePath = "Output_text212.psd";

PsdImage image = (PsdImage)Image.load(inFilePath);

try

{

    TextLayer textLayer = (TextLayer)image.getLayers()[1];

    IText textData = textLayer.getTextData();

    ITextStyle defaultStyle = textData.producePortion().getStyle();

    ITextParagraph defaultParagraph = textData.producePortion().getParagraph();

    defaultStyle.setFillColor(Color.getDimGray());

    defaultStyle.setFontSize(51);

    textData.getItems()[1].getStyle().setStrikethrough(true);

    ITextPortion[] newPortions = textData.producePortions(new String[] { "E=mc",  "2\r",  "Bold",  "Italic\r",  "Lowercasetext" }, defaultStyle, defaultParagraph);

    newPortions[0].getStyle().setUnderline(true); // 编辑文本样式 "E=mc"

    newPortions[1].getStyle().setFontBaseline(FontBaseline.Superscript); // 编辑文本样式 "2\r"

    newPortions[2].getStyle().setFauxBold(true); // 编辑文本样式 "Bold"

    newPortions[3].getStyle().setFauxItalic(true); // 编辑文本样式 "Italic\r"

    newPortions[3].getStyle().setBaselineShift(-25); // 编辑文本样式 "Italic\r"

    newPortions[4].getStyle().setFontCaps(FontCaps.SmallCaps); // 编辑文本样式 "Lowercasetext"

    for (ITextPortion newPortion : newPortions)

    {

        textData.addPortion(newPortion);

    }

    textData.updateLayerData();

    image.save(outFilePath);

}

finally

{

    image.dispose();

}

PSDJAVA-135. 支持黑白调整图层

 // 运行时支持添加黑白调整图层的示例。

String inFileName = "Stripes.psd";

String outFileName = "Output" + inFileName;

PsdImage image = (PsdImage)Image.load(inFileName);

try

{

    BlackWhiteAdjustmentLayer newLayer = image.addBlackWhiteAdjustmentLayer();

    newLayer.setName("BlackWhiteAdjustmentLayer");

    newLayer.setReds(22);

    newLayer.setYellows(92);

    newLayer.setGreens(70);

    newLayer.setCyans(79);

    newLayer.setBlues(7);

    newLayer.setMagentas(28);

    image.save(outFileName, new PsdOptions());

}

finally

{

    image.dispose();

}

// 黑白调整图层支持示例。

inFileName = "BlackWhiteAdjustmentLayerStripesMask.psd";

outFileName = "Output" + inFileName;

PsdImage image1 = (PsdImage)Image.load(inFileName);

try

{

    BlackWhiteAdjustmentLayer blwhLayer = (BlackWhiteAdjustmentLayer)image1.getLayers()[1];

    blwhLayer.setReds(15);

    blwhLayer.setYellows(25);

    blwhLayer.setGreens(35);

    blwhLayer.setCyans(10);

    blwhLayer.setBlues(50);

    blwhLayer.setMagentas(105);

    blwhLayer.setUseTint(true);

    blwhLayer.setBwPresetKind(4);

    blwhLayer.setBlackAndWhitePresetFileName("bwPresetFileName");

    blwhLayer.setTintColorRed(60);

    blwhLayer.setTintColorGreen(80);

    blwhLayer.setTintColorBlue(200);

    image1.save(outFileName, new PsdOptions());

}

finally

{

    image1.dispose();

}

PSDJAVA-137. 支持将AI格式(版本8)导出为其他格式

 // 将AI文件导出为PSD和PNG格式的示例。

String inFileName = "form_8.ai";

String outFileNamePrefix = "form_8_export";

AiImage image = (AiImage)Image.load(inFileName);

try

{

    image.save(outFileNamePrefix + ".psd", new PsdOptions());

    PngOptions pngOptions = new PngOptions();

    pngOptions.setColorType(PngColorType.TruecolorWithAlpha);

    image.save(outFileNamePrefix + ".png", pngOptions);

}

finally

{

    image.dispose();

}

PSDJAVA-138. 支持按通行通过混合模式处理(仅用于图层组)

 class LocalScope

{

    void assertIsTrue(boolean condition, String message)

    {

        if (!condition)

        {

            throw new FormatException(message);

        }

    }

}

LocalScope localScope = new LocalScope();

String inFileName = "Apple.psd";

String outFileName = "Output" + inFileName;

PsdImage image = (PsdImage)Image.load(inFileName);

try

{

    localScope.assertIsTrue(image.getLayers().length >= 23, "不存在第23个图层。");

    LayerGroup layer = (LayerGroup)image.getLayers()[23];

    localScope.assertIsTrue(layer != null, "第23个图层不是图层组。");

    localScope.assertIsTrue(layer.getName().equals("AdjustmentGroup"), "第23个图层名称不是'AdjustmentGroup'。");

    localScope.assertIsTrue(layer.getBlendModeKey() == BlendMode.PassThrough, "调整组图层应具有'pass through'混合模式。");

    image.save(outFileName, new PsdOptions());

    PngOptions pngOptions = new PngOptions();

    pngOptions.setColorType(PngColorType.TruecolorWithAlpha);

    image.save("OutputApple.png", pngOptions);

    layer.setBlendModeKey(BlendMode.Normal);

    image.save("Normal" + outFileName, new PsdOptions());

    PngOptions pngOptions1 = new PngOptions();

    pngOptions1.setColorType(PngColorType.TruecolorWithAlpha);

    image.save("NormalOutputApple.png", pngOptions1);

}

finally

{

    image.dispose();

}

PSDJAVA-136. 加载带有空Unicode Alpha Names资源的图像失败异常

 String inFilePath = "apple.psd";

PsdImage psdImage = null;

try

{

    // 这里不应该有异常

    psdImage = (PsdImage)Image.load(inFilePath);

}

finally

{

    if (psdImage != null) psdImage.dispose();

}

PSDJAVA-139. 更改图层组可见性后输出不正确

 String inFileName = "input.psd";

String outFileName = "output.psd";

// 更改图层名称并保存

PsdImage image = (PsdImage)Image.load(inFileName);

try

{

    for (int i = 0; i < image.getLayers().length; i++)

    {

        Layer layer = image.getLayers()[i];

        // 关闭组内的所有内容

        if (layer instanceof LayerGroup)

        {

            layer.setVisible(false);

        }

    }

    image.save(outFileName);

}

finally

{

    image.dispose();

}

PSDJAVA-140. 加载PSD图像时发生异常:颜色部分(DropShadow资源)必须包含RGB的3个颜色分量或CMYK的4个颜色分量

 String inFilePath = "sss0136=GUID-SSS0136=1=ar-sa=Low.psd";

PsdImage image = null;

try

{

    image = (PsdImage)PsdImage.load(inFilePath);

}

finally

{

    if (image != null) image.dispose();

}       

PSDJAVA-141. 如果使用简化版本的构造函数尝试在新创建的图层上绘制,则会引发异常

 String outputFile = "output.psd";

int width = 100;

int height = 100;

PsdImage image = new PsdImage(width, height);

try

{

    Layer layer = new Layer();

    layer.setBottom(height);

    layer.setRight(width);

    image.addLayer(layer);

    Graphics graphic = new Graphics(layer);

    graphic.clear(Color.getYellow());

    // 使用笔工具绘制矩形

    graphic.drawRectangle(new Pen(Color.getRed()), new Rectangle(30, 10, 40, 80));

    // 使用蓝色实心刷子绘制另一个矩形

    graphic.drawRectangle(new Pen(new SolidBrush(Color.getBlue())), new Rectangle(10, 30, 80, 40));

    image.save(outputFile);

}

finally

{

    image.dispose();

}