我有下面的代碼,用於將圖片從IOS設備上傳並調整到我的.net應用程序。用戶使用縱向拍照,然後所有照片以錯誤的旋轉顯示在我的應用程序中。任何建議如何解決這個問題?從IOS圖片上傳到.net應用程序:旋轉
string fileName = Server.HtmlEncode(FileUploadFormbilde.FileName);
string extension = System.IO.Path.GetExtension(fileName);
System.Drawing.Image image_file = System.Drawing.Image.FromStream(FileUploadFormbilde.PostedFile.InputStream);
int image_height = image_file.Height;
int image_width = image_file.Width;
int max_height = 300;
int max_width = 300;
image_height = (image_height * max_width)/image_width;
image_width = max_width;
if (image_height > max_height)
{
image_width = (image_width * max_height)/image_height;
image_height = max_height;
}
Bitmap bitmap_file = new Bitmap(image_file, image_width, image_height);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bitmap_file.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Position = 0;
byte[] data = new byte[stream.Length + 1];
stream.Read(data, 0, data.Length);
任何代碼示例?我無法找到如何在我的代碼中成功實現這一點。 –
對不起。你已經在正確的圖像對象,我給你一個鏈接來閱讀。我堅信重要的是要通過做,而不是通過複製粘貼代碼來學習。 (不是說有數百個代碼示例在那裏。) – Alexander