2012-01-07 105 views
1

如何使用PSD-plugin爲Paint.NET保存png中的psd圖層?如何使用PSD-plugin爲Paint.NET保存png中的psd圖層?

試圖做到這一點的方法:

System.Drawing.Image img; 
var stream = new System.IO.MemoryStream(); 
var BRW = new PhotoshopFile.BinaryReverseWriter(stream); 
var psd = new PhotoshopFile.PsdFile(); 
psd.Load("c:\\1.psd"); 
psd.Layers[0].Save(BRW); 
stream.Seek(0, System.IO.SeekOrigin.Begin); 
img = System.Drawing.Image.FromStream(stream, true, true); 
img.Save("c:\\1.png", System.Drawing.Imaging.ImageFormat.Png); 

但線 IMG = Image.FromStream(流,真實,TRUE); 拋出「參數無效」異常。

通過C#/ C++的任何其他解決方案也是可行的。提前致謝。

+0

可能的重複項:http://stackoverflow.com/q/629955/635634。這個問題最相關的答案基本上說你的流是腐敗的。我懷疑'System.Drawing.Image'理解psd格式。 – 2012-01-07 21:32:24

+0

不重複。我正在爲這個問題找到一個解決方案,而不是錯誤解決方案中錯誤的原因。 – kFk 2012-01-07 21:36:23

回答

0

你有沒有想過要問PSD插件的作者?順便說一句,Paint.NET沒有被許可用作SDK,只能作爲應用程序使用。

0

第一個解決方案不與最新版本不再起作用,而是使用:

var psd = new PhotoshopFile.PsdFile("YourPhotoshop Path as string", Encoding.ASCII); 

// or 

var psd = new PhotoshopFile.PsdFile("Your Photoshop File Path as string", Encoding.Default); 

同樣與節能。

相關問題