cs/img_slt.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Web;
using System.Drawing;
namespace web
{
public class img_slt
{
private static HttpContext context = HttpContext.Current;
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="originalImagePath">源图路径(物理路径)</param>
/// <param name="thumbnailPath">缩略图路径(物理路径)</param>
/// <param name="width">缩略图宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">生成缩略图的方式</param>
public static string sc(string originalImagePath)
{
string fig = "";
Image originalImage = Image.FromFile(originalImagePath);
string thumbnailPath = context.Server.MapPath("~/file/");
DateTime now = DateTime.Now; //获取系统时间
string hb = now.Year + "" + now.Month + "" + now.Day + "" + now.Hour + "" + now.Minute + "" + now.Second + "" + now.Millisecond + ".jpg";
thumbnailPath += hb;
fig = "/file/" + hb;
int towidth = 300;
int toheight = 300;
int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;
switch ("W")
{
case "HW"://指定高宽缩放(可能变形)
break;
case "W"://指定宽,高按比例
toheight = originalImage.Height * towidth / originalImage.Width;
break;
case "H"://指定高,宽按比例
towidth = originalImage.Width * toheight / originalImage.Height;
break;
case "Cut"://指定高宽裁减(不变形)
if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height * towidth / toheight;
y = 0;
x = (originalImage.Width - ow) / 2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width * toheight / towidth;
后面还有 49 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。