.Net GDI+缩放绘图
时间:2010-12-27 来源:New.min
目的将9.JPG绘成600px * 400px的图片
代码如下:
using System.IO; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; public void PrintImage() { //原图片尺寸1200*800 Bitmap img = new Bitmap("9.jpg"); Bitmap img2 = new Bitmap(600,400); //设置分辨率 img2.SetResolution(600f, 600f); //从img2画图 Graphics g = Graphics.FromImage(img2); //将img2上的坐标(0,0)绘出img g.DrawImage(img, new Point(0, 0)); //划出水平和垂直的分辨率 g.DrawString(img2.HorizontalResolution + "/" + img2.VerticalResolution, new Font("Tahoma",1.5f), Brushes.Black, new PointF(2, 2)); g.DrawString("www.ops.cc", new Font(FontFamily.GenericSansSerif, 1.5f), Brushes.Blue, new PointF(2,14)); g.Dispose(); img2.Dispose(); img.Dispose(); }
相关阅读 更多 +