Renderowanie tekstu o różnych kolorach w warstwie tekstu

Renderowanie tekstu o różnych kolorach w warstwie tekstu

Aspose.PSD obsługuje konwersję plików PSD na obrazy. Mogą występować przypadki, gdy tekst w pliku PSD zawiera różne kolory. Aspose.PSD obsługuje konwertowanie takich plików PSD na obrazy.

Poniższy fragment kodu demonstruje konwertowanie pliku PSD z różnymi kolorami w warstwie tekstu na PNG

// 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();
}