优化上传商品图片

This commit is contained in:
wule committed 2026-10-21 13:43:16 +08:00
1 parent 059ac932a0
commit a09596378b
4 files changed
+149 -116

No files matched your search

+24 -9
View File
@@ -592,17 +592,32 @@ namespace AllBase
public static Image LoadBitmapLoadBitmipImageFromUrl(string url, out string error)
{
try
BitmapImage bi = null;
try
{
BitmapImage bi = LoadBitmipImageFromUrl(url, out error);
return BitmapImageToSystemDrawingImage(bi);
bi = LoadBitmipImageFromUrl(url, out error);
if (bi == null || !string.IsNullOrEmpty(error))
{
error = "获取图片失败 " + error;
return null;
}
}
catch (Exception e)
{
error = e.Message;
error = "获取图片失败 " + e.Message;
return null;
}
}
try
{
return BitmapImageToSystemDrawingImage(bi);
}
catch (Exception e)
{
error = "转换图片失败 " + e.Message;
return null;
}
}
public static Image BitmapImageToSystemDrawingImage(BitmapImage bitmapImage)
{
@@ -632,10 +647,10 @@ namespace AllBase
Bitmap bitmap = new Bitmap(stream);
stream.Close();
//// 现在你可以将这个Bitmap对象用于Windows Forms的PictureBox或其他图像显示控件
//PictureBox pictureBox = new PictureBox();
//pictureBox.Image = bitmap; // 或者如果你已经有了一个PictureBox控件,直接设置其Image属性
return bitmap;
//// 现在你可以将这个Bitmap对象用于Windows Forms的PictureBox或其他图像显示控件
//PictureBox pictureBox = new PictureBox();
//pictureBox.Image = bitmap; // 或者如果你已经有了一个PictureBox控件,直接设置其Image属性
return bitmap;
}
}