讀取圖片文件(C#實現)


 1  /// <summary>
 2         /// 讀取圖片文件
 3         /// </summary>
 4         /// <param name="path">圖片文件路徑</param>
 5         /// <returns>圖片文件</returns>
 6         private Bitmap ReadImageFile(String path)
 7         {
 8             Bitmap bitmap=null;
 9             try
10             {
11                 FileStream fileStream = File.OpenRead(path);
12                 Int32 filelength = 0;
13                 filelength = (int)fileStream.Length;
14                 Byte[] image = new Byte[filelength];
15                 fileStream.Read(image, 0, filelength);
16                 System.Drawing.Image result = System.Drawing.Image.FromStream(fileStream);
17                 fileStream.Close();
18                 bitmap = new Bitmap(result);
19             }
20             catch (Exception ex)
21             { 
22                 //  異常輸出
23             }
24             return bitmap;
25         }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM