优化图片旋转的问题
This commit is contained in:
parent
efd32688fc
commit
b0700e195b
|
|
@ -1499,7 +1499,6 @@ public class CommonUse
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,9 +314,8 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
|
||||||
Response.Write("NO DATA");
|
Response.Write("NO DATA");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Bitmap PictureBoxBitMap = ImgGet(dt.Rows[0]["TempPicture64_nvarchar"].ToString());
|
Bitmap PictureBoxBitMap = UrlToImage(dt.Rows[0]["TempPicture64_nvarchar"].ToString());
|
||||||
|
|
||||||
//var PictureBoxBitMap = commonUse.RotateByOrientation(tempPictureBoxBitMap);
|
|
||||||
if (PictureBoxBitMap == null)
|
if (PictureBoxBitMap == null)
|
||||||
{
|
{
|
||||||
Response.Write("NO PICTURE");
|
Response.Write("NO PICTURE");
|
||||||
|
|
@ -337,7 +336,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
|
||||||
|
|
||||||
Image<Bgr, byte> myImage = new Image<Bgr, byte>(PictureBoxBitMap);
|
Image<Bgr, byte> myImage = new Image<Bgr, byte>(PictureBoxBitMap);
|
||||||
// 进行中值滤波
|
// 进行中值滤波
|
||||||
CvInvoke.MedianBlur(myImage, myImage, 13);
|
CvInvoke.MedianBlur(myImage, myImage, 11);
|
||||||
// 进行高斯滤波
|
// 进行高斯滤波
|
||||||
CvInvoke.GaussianBlur(myImage, myImage, new Size(0, 0), 3);
|
CvInvoke.GaussianBlur(myImage, myImage, new Size(0, 0), 3);
|
||||||
|
|
||||||
|
|
@ -352,7 +351,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
|
||||||
VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1);
|
VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1);
|
||||||
|
|
||||||
//var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1);
|
//var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1);
|
||||||
//commonUse.ShowMatWaitKey("44444", color_mat1, 0.6);
|
//commonUse.ShowMatWaitKey("44444", color_mat1, 0.8);
|
||||||
|
|
||||||
//Response.Write(ImgToBase64String(color_mat1.Bitmap));
|
//Response.Write(ImgToBase64String(color_mat1.Bitmap));
|
||||||
//return false;
|
//return false;
|
||||||
|
|
@ -1098,6 +1097,43 @@ public partial class 外部答题卡_Default : System.Web.UI.Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Bitmap UrlToImage(string url)
|
||||||
|
{
|
||||||
|
WebRequest imgRequest = WebRequest.Create(url);
|
||||||
|
|
||||||
|
HttpWebResponse res = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
res = (HttpWebResponse)imgRequest.GetResponse();
|
||||||
|
imgRequest.Timeout = 50000;
|
||||||
|
if (res.StatusCode.ToString() == "OK")
|
||||||
|
{
|
||||||
|
var tempbitmap = new Bitmap(imgRequest.GetResponse().GetResponseStream());
|
||||||
|
|
||||||
|
// 别删!图片和网页中的方向不一致,根据图片中的方向信息,旋转图片后识别
|
||||||
|
return new CommonUse().RotateByOrientation(tempbitmap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (WebException ex)
|
||||||
|
{
|
||||||
|
res = (HttpWebResponse)ex.Response;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.Dispose();
|
||||||
|
res.Close();
|
||||||
|
}
|
||||||
|
imgRequest.Abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,8 @@ public partial class Temp_TempDraw : System.Web.UI.Page
|
||||||
imgRequest.Timeout = 50000;
|
imgRequest.Timeout = 50000;
|
||||||
if (res.StatusCode.ToString() == "OK")
|
if (res.StatusCode.ToString() == "OK")
|
||||||
{
|
{
|
||||||
return new Bitmap(imgRequest.GetResponse().GetResponseStream());
|
var tempbitmap = new Bitmap(imgRequest.GetResponse().GetResponseStream());
|
||||||
|
return new CommonUse().RotateByOrientation(tempbitmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,8 @@ public partial class Temp_UserTemp : System.Web.UI.Page
|
||||||
Response.Write("NODATA");
|
Response.Write("NODATA");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bitmap PictureBoxBitMap = ImgGet(dt.Rows[0]["TempPicture64_nvarchar"].ToString());
|
Bitmap temp = ImgGet(dt.Rows[0]["TempPicture64_nvarchar"].ToString());
|
||||||
|
var PictureBoxBitMap = new CommonUse().RotateByOrientation(temp);
|
||||||
if (PictureBoxBitMap == null)
|
if (PictureBoxBitMap == null)
|
||||||
{
|
{
|
||||||
Response.Write("NOPICTURE");
|
Response.Write("NOPICTURE");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue