# 影像處理

參考資料:Bitmap(<https://msdn.microsoft.com/zh-tw/library/system.drawing.bitmap(v=vs.110).aspx>)

## BitmapToByte

參考資料:(<http://blog.udn.com/yccsonar/28112333>)

額外參考資料:(<https://stackoverflow.com/questions/7350679/convert-a-bitmap-into-a-byte-array>)

```
     byte[] content;
     System.Drawing.Bitmap srcImage = new System.Drawing.Bitmap(ImgPath + ImgName);
     MemoryStream ms = new MemoryStream();
     srcImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
     content = ms.GetBuffer();
```

## 在GDI+ 中發生泛型錯誤

參考資料:(<https://blog.miniasp.com/post/2009/05/30/A-generic-error-occurred-in-GDI-plus.aspx>)

### 跟C#語法無關

#### 與檔案系統相關

確認目錄權限，是否無法寫入、無法讀取。

確認檔案權限，是否無法寫入、無法讀取。

目錄是否存在。

#### 與圖檔格式相關

無法轉換的圖檔類型

透過Image.FromStream 載入圖片時無法使用Seek方法

輸入的編碼有問題。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brianwu.gitbook.io/brian/brians-za-ji/ying-xiang-chu-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
