이미지로 계층 그룹 내보내기
Contents
[
Hide
]
이미지로 계층 그룹 내보내기
Aspose.PSD는 레이어 그룹을 이미지로 내보낼 수 있습니다. 이를 위해 API는 LayerGroup 클래스를 제공합니다.
예제
다음 코드 스니펫은 레이어 그룹을 이미지로 내보내는 방법을 보여줍니다.
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-.NET | |
string outputPng = "LayerGroup.psd_folder.png"; | |
using (PsdImage psdImage = new PsdImage(100, 100)) | |
{ | |
// Init background layer | |
var bgLayer = FillLayer.CreateInstance(FillType.Color); | |
((IColorFillSettings)bgLayer.FillSettings).Color = Color.Blue; | |
// Init regular layers | |
byte[] tempBytes = new byte[10 * 10]; | |
Layer layer1 = new Layer( | |
new Rectangle(50, 50, 10, 10), tempBytes, tempBytes, tempBytes, "Layer 1"); | |
Layer layer2 = new Layer( | |
new Rectangle(50, 50, 10, 10), tempBytes, tempBytes, tempBytes, "Layer 2"); | |
// Init and add folder | |
LayerGroup layerGroup = psdImage.AddLayerGroup("Folder", 0, true); | |
// add background to PsdImage | |
psdImage.AddLayer(bgLayer); | |
// add regular layers to folder | |
layerGroup.AddLayer(layer1); | |
layerGroup.AddLayer(layer2); | |
// Validate that the layers were added correctly | |
System.Diagnostics.Debug.Assert(layerGroup.Layers[0].DisplayName == "Layer 1"); | |
System.Diagnostics.Debug.Assert(layerGroup.Layers[1].DisplayName == "Layer 2"); | |
psdImage.Save(outputPsd); | |
layerGroup.Save(outputPng, new PngOptions()); | |
} |
자세한 정보 및 예제는 Aspose.PSD for C# documentation을 방문해 주세요.