InfxResource 지원
Contents
[
Hide
]
InfxResource 지원
InfxResource에는 내부 요소의 혼합에 관한 데이터가 포함되어 있습니다. Aspose.PSD는 PSD 파일에서 InfxResource를 지원합니다. 이를 위해 API는 InfxResource 클래스를 제공합니다.
다음 코드 조각은 Aspose.PSD가 InfxResource를 지원하는 방법을 보여줍니다.
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
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-Java | |
public static void main(String[] args) { | |
String sourceDir = Utils.GetDataDir_PSD(); | |
String outputDir = Utils.GetDataDir_Output(); | |
String sourceFileName = sourceDir + "SampleForInfxResource.psd"; | |
String destinationFileName = outputDir + "SampleForInfxResource_out.psd"; | |
boolean isRequiredResourceFound = false; | |
PsdImage im = null; | |
try { | |
im = (PsdImage) Image.load(sourceFileName); | |
for (Layer layer : im.getLayers()) { | |
for (LayerResource layerResource : layer.getResources()) { | |
if (layerResource instanceof InfxResource) { | |
InfxResource resource = (InfxResource) layerResource; | |
isRequiredResourceFound = true; | |
assertIsTrue(!resource.getBlendInteriorElements(), "The InfxResource.BlendInteriorElements should be false"); | |
// Test editing and saving | |
resource.setBlendInteriorElements(true); | |
im.save(destinationFileName); | |
break; | |
} | |
} | |
} | |
} finally { | |
if (im != null) im.dispose(); | |
} | |
assertIsTrue(isRequiredResourceFound, "The specified InfxResource not found"); | |
isRequiredResourceFound = false; | |
PsdImage im2 = null; | |
try { | |
im2 = (PsdImage) Image.load(destinationFileName); | |
for (Layer layer : im2.getLayers()) { | |
for (LayerResource layerResource : layer.getResources()) { | |
if (layerResource instanceof InfxResource) { | |
InfxResource resource = (InfxResource) layerResource; | |
isRequiredResourceFound = true; | |
assertIsTrue(resource.getBlendInteriorElements(), "The InfxResource.BlendInteriorElements should change to true"); | |
break; | |
} | |
} | |
} | |
} finally { | |
if (im2 != null) im2.dispose(); | |
} | |
assertIsTrue(isRequiredResourceFound, "The specified InfxResource not found"); | |
} | |
private static void assertIsTrue(boolean condition, String message) { | |
if (!condition) { | |
throw new FormatException(message); | |
} | |
} |