旋转文本图层的渲染
Contents
[
Hide
]
旋转文本图层的渲染
Aspose.PSD提供了旋转文本图层的渲染功能。在下面的示例中,通过将文件路径传递给Image类的静态Load方法来加载现有的PSD文件。现在调用PsdImage实例的Save方法。
以下代码片段展示了如何渲染旋转的文本图层。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(RenderingOfRotatedTextLayer.class) + "PSD/"; | |
String sourceFileName = dataDir + "TransformedText.psd"; | |
String exportPath = dataDir + "TransformedTextExport.psd"; | |
String exportPathPng = dataDir + "TransformedTextExport.png"; | |
try (PsdImage im = (PsdImage) Image.load(sourceFileName)) { | |
PngOptions opt = new PngOptions(); | |
opt.setColorType(PngColorType.Grayscale); | |
im.save(exportPath); | |
im.save(exportPathPng, opt); | |
} | |
} |
旋转矢量蒙版和文本图层
Aspose.PSD提供了旋转矢量蒙版和文本图层的功能。Aspose.PSD暴露了RotateFlip方法来旋转矢量蒙版和文本图层。旋转图层的步骤如下所示:
- 使用Image类的工厂方法Load将PSD文件加载为图像。
- 设置所需的RotateFlipType。
- 调用RotateFlip方法。
- 保存结果。
以下代码片段展示了如何旋转矢量蒙版和文本图层。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(SupportOfRotateLayer.class) + "PSD/"; | |
String sourceFile = dataDir + "1.psd"; | |
String pngPath = dataDir + "RotateFlipTest2617.png"; | |
String psdPath = dataDir + "RotateFlipTest2617.psd"; | |
int flipType = RotateFlipType.Rotate270FlipXY; | |
try (PsdImage im = (PsdImage) Image.load(sourceFile)) { | |
im.rotateFlip(flipType); | |
PngOptions options = new PngOptions(); | |
options.setColorType(PngColorType.TruecolorWithAlpha); | |
im.save(pngPath, options); | |
im.save(psdPath); | |
} |