คู่มือเร็วเริ่มต้น Aspose.PSD Adapters for .NET

การใช้งานง่าย

Aspose.PSD Adapters สำหรับ .NET เป็นแพ็กเกจ Nuget พิเศษที่ช่วยให้คุณเขียนโค้ดการผสมรวมกับผลิตภัณฑ์ Aspose อื่น ๆ ได้ง่ายขึ้น

เพื่อเริ่มใช้ Aspose.PSD Adapters กรุณาตรวจสอบคำแนะนำต่อไปนี้:

  1. อ้างอิง Aspose.PSD.Adapters.Imaging จาก Nuget หรือดาวน์โหลดได้จาก Aspose Release Page(Adapters รวมไว้ในผลิตภัณฑ์หลักในช่วงเวลานี้) ไปยังโปรเจคของคุณ การอ้างอิงที่จำเป็น
  • โปรดทราบ: หากคุณใช้ Aspose.PSD.Adapters จาก https://releases.aspose.com/psd/net/ คุณจำเป็นต้องอ้างอิง Aspose.Drawing และ Aspose.Imaging จาก nuget หรือไฟล์โลคอลเพิ่มเติม
  1. เพิ่มโค้ดต่อไปนี้:
// This code allows to load the specified formats
Aspose.PSD.Adapters.Imaging.EnableLoaders(
FileFormat.Svg,
FileFormat.Webp);
// This code allows you to export using adapters
Aspose.PSD.Adapters.Imaging.EnableExporters();
// To work with adapters you need both Aspose.PSD and adaptee Licenses
var license = new Aspose.PSD.License();
license.SetLicense(@"Aspose.PSD.NET.lic");
var licImaging = new Aspose.Imaging.License();
licImaging.SetLicense(@"Aspose.Imaging.NET.lic");
// Aspose.Imaging loading and integration with PSD format will be provided seamless in this case.
using (var image = Image.Load(@"SomeFile.Webp"))
{
// Saving in this example is provided by Aspose.PSD
image.Save(@"output.png", new PngOptions() { ColorType = Aspose.PSD.FileFormats.Png.PngColorType.TruecolorWithAlpha });
}
  1. นั้นคือทุกอย่างที่คุณต้องใช้ adapters

การส่งออกและโหลดพร้อมกับตัวเลือกเพิ่มเติมเฉพาะ Adaptee

ในกรณีส่วนมากนั้นมักเพียงพอที่จะใช้ตัวอย่างแรก แต่ในกรณีของโซลูชั่นขนาดใหญ่บ้างครั้งต้องการทำการแปลงพร้อมกับตัวเลือกเพิ่มเติม กรุณาตรวจสอบตัวอย่างต่อไปนี้:

// Create new Imaging-only supported Image (Can be used SVG, or any other not-supported in PSD Format)
using (WebPImage webp = new WebPImage(300, 300, null))
{
// Use Aspose.Imaging API to Edit WEBP file with Imaging-specific features
var gr = new Aspose.Imaging.Graphics(webp);
gr.Clear(Aspose.Imaging.Color.Wheat);
gr.DrawArc(
new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 5),
new Aspose.Imaging.Rectangle(50, 50, 200, 200),
0,
270);
// Then just use ToPsdImage() method and edit file like PSD with Photoshop-like features including layers, smart filters and smart objects.
using (var psdImage = webp.ToPsdImage())
{
psdImage.AddTextLayer("Some text", new Rectangle(100, 100, 100, 50));
var hue = psdImage.AddHueSaturationAdjustmentLayer();
hue.Hue = 130;
// Save the final PSD file using Aspose.PSD
psdImage.Save("output.psd");
}
}

ณจุดนี้คุณไม่จำเป็นต้องเขียนโค้ดเพิ่มเติมใด ๆ Adapters จะให้การผสมรวมได้อย่างราบรื่นกับ API ของ Aspose.PSD และ Adaptees ของมัน