إضافة طبقة إلى ملف PSD
Contents
[
Hide
]
نظرة عامة
إنه حالة شائعة الاستخدام. كل ما تحتاج إليه هو فتح الملف الذي تحتاجه كتيار ثم استخدام Aspose.PSD لإضافة هذا الملف كطبقة جديدة. يمكنك أيضًا تغيير ترتيب الطبقات في ملف PSD.
لإضافة ملف جرافيكي كطبقة إلى PSD، استخدم الشيفرة التالية:
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 outputFilePath = dataDir + "PsdResult.psd"; | |
var filesList = new string[] | |
{ | |
"PsdExample.psd", | |
"BmpExample.bmp", | |
"GifExample.gif", | |
"Jpeg2000Example.jpf", | |
"JpegExample.jpg", | |
"PngExample.png", | |
"TiffExample.tif", | |
}; | |
using (var image = new PsdImage(200, 200)) | |
{ | |
foreach (var fileName in filesList) | |
{ | |
string filePath = dataDir + fileName; | |
using (var stream = new FileStream(filePath, FileMode.Open)) | |
{ | |
Layer layer = null; | |
try | |
{ | |
layer = new Layer(stream); | |
image.AddLayer(layer); | |
} | |
catch (Exception e) | |
{ | |
if (layer != null) | |
{ | |
layer.Dispose(); | |
} | |
throw e; | |
} | |
} | |
} | |
image.Save(outputFilePath); | |
} |
لتغيير ترتيب الطبقات، يُرجى الاطلاع على مرجع API طبقات PSD في فئة صورة Psd