Render text with different colors in Text Layer
Contents
[
Hide
]
텍스트 레이어에서 다른 색상으로 텍스트 렌더링
Aspose.PSD는 PSD 파일을 이미지로 변환하는 기능을 지원합니다. PSD 파일의 텍스트에 서로 다른 색상이 포함된 경우가 있을 수 있습니다. Aspose.PSD는 이러한 PSD 파일을 이미지로 변환하는 기능을 지원합니다.
다음 코드 스니펫은 텍스트 레이어의 다른 색상이 포함된 PSD 파일을 PNG로 변환하는 방법을 보여줍니다.
This file contains hidden or 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
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-Java | |
String sourceDir = Utils.GetDataDir_PSD(); | |
String outputDir = Utils.GetDataDir_Output(); | |
String targetFilePath = sourceDir + "text_ethalon_different_colors.psd"; | |
String resultFilePath = outputDir + "RenderTextWithDifferentColorsInTextLayer_out.png"; | |
PsdImage psdImage = null; | |
try { | |
psdImage = (PsdImage) Image.load(targetFilePath); | |
TextLayer txtLayer = (TextLayer) psdImage.getLayers()[1]; | |
txtLayer.getTextData().updateLayerData(); | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.setColorType(PngColorType.TruecolorWithAlpha); | |
psdImage.save(resultFilePath, pngOptions); | |
} finally { | |
if (psdImage != null) psdImage.dispose(); | |
} |