提交当前本机整理版本
This commit is contained in:
@@ -575,4 +575,40 @@ public static class LabPicUrlPreview
|
||||
// 为避免对流的依赖,先 Image.FromStream,再复制
|
||||
using (Image img = Image.FromStream(ms))
|
||||
{
|
||||
return new B
|
||||
return new Bitmap(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Image ScaleBitmap(Bitmap src, int targetHeight)
|
||||
{
|
||||
int h = targetHeight <= 0 ? 30 : targetHeight;
|
||||
if (h < 18) h = 18;
|
||||
double ratio = (double)h / (double)src.Height;
|
||||
int w = (int)Math.Round((double)src.Width * ratio);
|
||||
if (w < 1) w = 1;
|
||||
return new Bitmap(src, new Size(w, h));
|
||||
}
|
||||
|
||||
private static Image CopyBitmap(Bitmap src)
|
||||
{
|
||||
return new Bitmap(src);
|
||||
}
|
||||
|
||||
private static void BeginInvokeSafe(System.Windows.Forms.Control c, Action action)
|
||||
{
|
||||
if (action == null) return;
|
||||
try
|
||||
{
|
||||
if (c != null && !c.IsDisposed)
|
||||
c.BeginInvoke(action);
|
||||
else
|
||||
action();
|
||||
}
|
||||
catch
|
||||
{
|
||||
try { action(); } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user