关于图片截取出现的问题
lk829 2008-03-20 05:16:00 有一个(110*135)固定的选取框 可以任意移动图片位置至选取框中截取自己想要的地方!
图片可以用js控制放大缩小
现在是如果在图片不放大或缩小的情况下 截取的图片区域是对的 如果在把图片放大或缩小了
截取的区域就会错位 百思不得其解 错在哪了
像各位请教了!
代码如下:
/// 截图
/// </summary>
/// <param name="imgW">新图片的宽度</param>
/// <param name="x">坐标x</param>
/// <param name="y">坐标y</param>
private void NewMethod1(int imgW, int x, int y)
{
System.Drawing.Image imgOutput = System.Drawing.Bitmap.FromFile(Server.MapPath("img/http_imgload.jpg"));
Bitmap b = new Bitmap(110, 135, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(b);
int imgH = imgOutput.Height * imgW / imgOutput.Width;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(imgOutput, new Rectangle(0, 0, imgW, imgH), new Rectangle(x, y, imgOutput.Width, imgOutput.Height), GraphicsUnit.Pixel);
g.SmoothingMode = SmoothingMode.AntiAlias;
Response.ContentType = "image/jpeg";
string l = Server.MapPath("img/222.jpg");
b.Save(l);
b.Dispose();
}