Metin Katmanında Farklı Renklerle Metin Oluşturma
Contents
[
Hide
]
Metin Katmanında Farklı Renklerle Metin Oluşturma
Aspose.PSD, PSD dosyalarını resimlere dönüştürmeyi destekler. PSD dosyasındaki metnin farklı renklere sahip olduğu durumlar olabilir. Aspose.PSD, bu tür PSD dosyalarını resimlere dönüştürmeyi destekler.
Aşağıdaki kod parçası, Metin Katmanında farklı renklere sahip bir PSD dosyasını PNG’ye dönüştürmenin nasıl yapıldığını göstermektedir
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(); | |
} |