تصدير مجموعة الطبقات إلى صورة

تصدير مجموعة الطبقات إلى صورة

Aspose.PSD تدعم تصدير مجموعات الطبقات إلى صور. لهذا الغرض، يوفر الواجهة البرمجية (API) فئة LayerGroup.

مثال

توضح مقتطفات الكود التالية تصدير مجموعات الطبقات إلى صور.

// 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 لتوثيق C#.