Bitmap b = new Bitmap(newW, newH);
Graphics g = Graphics.FromImage(b);
// 插值算法的质量
g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
g.Dispose(); return b;
我在代码中,指定矩形区域的左上角坐标也不好使。不知为什么,请大侠们指教!
解决方案 »
- 用GridView发布分类新闻如何提高效率?用一个GridView还是几个?
- ==================强烈要求CSND换回原版=================
- 声明一个color类数组问题
- 第一个NHibernate例子就出错,大家来看看 !!
- 页面include了js代码文件,为何找不到js文件里面的函数?
- 关于用c#在asp.net中和word,excl的交互,急...谢谢
- 菜鸟小问题,关于控件组件~
- 怎么给DataPager里的DropDownList动态添加项?
- DataGrid模板列数据绑定问题。
- 关于interface接口,.net中新增的功能,讨论一下,up也有分
- 求高人指点一个网页布局的问题,谁会给谁分
- win2008 未能加载文件或程序集System.Transactions
指定左上角X Y坐标
Graphics.DrawImage 方法 (Image, Rectangle, Int32, Int32, Int32, Int32, GraphicsUnit)
http://msdn.microsoft.com/zh-cn/library/ms142045.aspx
System.Drawing.Image orgImage = System.Drawing.Image.FromFile(Path.Combine(Server.MapPath("图片路径"), strFileName));
x = 100;
y = 50;
w = 150;
h = 80;
System.Drawing.Image currentImage = new Bitmap(240, 120, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Graphics g = Graphics.FromImage(currentImage);
Rectangle destRect = new Rectangle(0, 0, 240, 120);
Rectangle srcRect = new Rectangle(x, y, w, h);
g.DrawImage(orgImage, destRect, srcRect, GraphicsUnit.Pixel);
g.Dispose();
orgImage.Dispose();
像上面这样就可以了!