การสนับสนุนของ SoCoResource
Contents
[
Hide
]
การสนับสนุนของ SoCoResource
SoCoResource ประกอบด้วยข้อมูลเกี่ยวกับเลเยอร์ Color Fill. บทความนี้จะสาธิตว่า Aspose.PSD สำหรับ .NET สนับสนุน SoCoResource ในไฟล์ PSD
- โหลดไฟล์ PSD เป็นภาพโดยใช้วิธีการโรงงานโหลดที่เปิดเผยโดยคลาสภาพ Image
- รับ SoCoResource จากเลเยอร์ภาพ
- ตั้งค่าที่ต้องการจากผลลัพธ์
- บันทึกผลลัพธ์
โค้ดย่อยต่อไปนี้แสดงวิธีการ Aspose.PSD สำหรับ .NET สนับสนุน SoCoResource.
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 sourceFileName = dataDir + "ColorFillLayer.psd"; | |
string exportPath = dataDir + "SoCoResource_Edited.psd"; | |
var im = (PsdImage)Image.Load(sourceFileName); | |
using (im) | |
{ | |
foreach (var layer in im.Layers) | |
{ | |
if (layer is FillLayer) | |
{ | |
var fillLayer = (FillLayer)layer; | |
foreach (var resource in fillLayer.Resources) | |
{ | |
if (resource is SoCoResource) | |
{ | |
var socoResource = (SoCoResource)resource; | |
if (socoResource.Color != Color.FromArgb(63, 83, 141)) | |
{ | |
throw new Exception("Color from SoCoResource was read wrong"); | |
} | |
socoResource.Color = Color.Red; | |
break; | |
} | |
} | |
break; | |
} | |
im.Save(exportPath); | |
} | |
} |