如果我從RGB 8位複製一個區域從Photoshop到Clipboard.GetImage()
有黑白圖像,但如果我將其更改爲索引模式(256)GetImage
返回一個彩色圖像。c#Clipboard.GetImage()從Photoshop區域返回ab/w圖像
我也嘗試過使用GetDataObject
方法,但結果相同。看來圖像格式是memoryBMP,但在RGB/8格式,所以我無法獲得全綵色圖像。
如何從Photoshop剪貼板格式檢索彩色圖像回到我的C#應用程序?
這是我正在使用的代碼。該圖像被保存,但..
如果我複製像素從在Photoshop模式的圖像
RGB/8
其保存爲b /瓦。如果模式爲
index
(256色),則會節省顏色。
數據的圖像格式的類型爲:
[ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e] MemoryBMP
以下是我的C#代碼...
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Dib))
{
Bitmap image = (System.Drawing.Image)data.GetData(DataFormats.Dib, false) as Bitmap;
var encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
var encParams = new EncoderParameters(1);
encParams.Param[0] = new EncoderParameter(Encoder.ColorDepth, 24L);
image.Save("encode.jpg", encoder, encParams);
}
我沒有downvote,但我認爲你必須**顯示一些可測試代碼**,以允許其他人重新創建和/或修復你的問題...... PS:記住RGB 8位是真的的24位顏色(因爲8位紅色+8綠色+8藍色)。如果這樣可以幫助你。 –
感謝您的回答。我的第一篇文章,學習規則... – alexeef
您的帖子下有一個小[**'edit' **](https://stackoverflow.com/posts/46576473/edit)按鈕。或者只是使用鏈接(添加'/編輯'到頁面url):https://stackoverflow.com/posts/46576473/edit –