App_Code/common2/common/Images.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
namespace RM.Common
{
public class Images
{
public static Image GetFromStream(Stream fileStream)
{
Image Img = Image.FromStream(fileStream);
return Img;
}
public static Image GetFromFile(string filePath)
{
Image Img = Image.FromFile(filePath);
return Img;
}
#region//IsImgFitSize:判断图片是否适合比例.
public static bool IsImgFitSize(Image Img ,int maxWidth, int maxHeight)
{
return (Img.Width <= maxWidth && Img.Height <= maxHeight);
}
public static bool IsImgFitSize(Stream fileStream, int maxWidth, int maxHeight)
{
Image Img = GetFromStream(fileStream);
return IsImgFitSize(Img, maxWidth, maxHeight);
}
public static bool IsImgFitSize(string filePath, int maxWidth, int maxHeight)
{
Image Img = GetFromFile(filePath);
return IsImgFitSize(Img, maxWidth, maxHeight);
}
#endregion
#region//SetImageResize:重新设置图片大小统一保存成JPG格式.
public static void SetImageResize(Image Img, string strFileName, int maxWidth, int maxHeight)
{
if (Img.Width > maxWidth || Img.Height > maxHeight)
{
int oWidth = Img.Width; //原图宽度
int oHeight = Img.Height; //原图高度
//按比例计算出缩略图的宽度和高度
if (oWidth >= oHeight)
{
maxHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(maxWidth) / Convert.ToDouble(oWidth)));
}
else
{
maxWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(maxHeight) / Convert.ToDouble(oHeight)));
}
////Img = Img.GetThumbnailImage(maxWidth, maxHeight, null, IntPtr.Zero);
后面还有 186 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。