byte[] imageData=(byte[])row["Image"];
//↑讀進來的圖片檔案就有一定的尺寸了,不過寬不是200
MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length);
Image graph = Image.FromStream(ms);
這個是寬度P_Width = 200;
P_Height這個高度用等比例 =((P_Width)
/ (graph.Width)) * (graph.Height));
Bitmap imageOut = new Bitmap(graph,P_Width,P_Height);
imageOut.Save(放路徑接.jpg檔名);
graph.Dispose();
imageOut.Dispose();
ms.Close();
文章標籤
全站熱搜

感謝您的分享,但是經過實際測試 計算高度的時候,應該全部轉換成float,計算之後再轉回int 否則會有長寬不等比例的問題 P_Height =Convert.ToInt32((float)P_Width / (float)graph.Width * (float)graph.Height);