} catch (Exception ex) { MessageShow("生成图片错误!" + ex.Message); throw; } graphics.Dispose(); bitmap.Dispose(); }
// 图像压扁 protected void btnStave_Click(object sender, EventArgs e) { System.Drawing.Image img = System.Drawing.Image.FromFile(path); // 宽度不变 int w = img.Width; // 高度为原始高度的1/2 int h = img.Height / 2;
// 防止过度变形 if (w < 1) w = 10; if (h < 1) h = 0; bitmap = new Bitmap(w, h); graphics = Graphics.FromImage(bitmap); graphics.DrawImage(img, 0, 0, w, h); try { bitmap.Save(Server.MapPath("./_Stave.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg); MessageShow("已经生成图片,路径为" + @Server.MapPath("./_Stave.jpg").Replace("", "\"));
} catch (Exception ex) { MessageShow("生成图片错误!" + ex.Message); throw; } graphics.Dispose(); bitmap.Dispose(); } //图像拉宽 protected void btnElongate_Click(object sender, EventArgs e) { System.Drawing.Image img = System.Drawing.Image.FromFile(path); // 放大宽度 int w = img.Width / 2; // 高度不变 int h = img.Height;
(编辑:焦作站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|