日期:2014-05-17 浏览次数:20825 次
Bitmap bmp = new Bitmap(1000,1000); Image image = Image.FromHbitmap(bmp.GetHbitmap()); Graphics gra = Graphics.FromImage(image); Font drawFont=new System.Drawing.Font( new FontFamily( "SimSun"),800,FontStyle.Bold); gra.FillRectangle(Brushes.Black,0,0,1000,1000); gra.DrawString("1", drawFont, Brushes.White, new PointF(100,0)); image.Save("c:\\test.jpg"); gra.Dispose(); image.Dispose(); bmp.Dispose();
------解决方案--------------------
LS正解
------解决方案--------------------
2L正解 背景图片可以自己加 或者 自己用随机函数在画刷填充矩形后自己随机位置添加一些小图形 最后加上自己的数字。
------解决方案--------------------
Bitmap bmp = new Bitmap(1000,1000); Image image = Image.FromHbitmap(bmp.GetHbitmap()); Graphics gra = Graphics.FromImage(image); Font drawFont=new System.Drawing.Font( new FontFamily( "SimSun"),800,FontStyle.Bold); gra.FillRectangle(Brushes.Black,0,0,1000,1000); for(int i=1;i<=600;i++) { gra.DrawString("1", drawFont, Brushes.White, new PointF(100,0)); image.Save("c:\\test{0}.jpg",i); } gra.Dispose(); image.Dispose(); bmp.Dispose();
------解决方案--------------------
using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Bitmap bmp = new Bitmap(1000, 1000); Image image = Image.FromHbitmap(bmp.GetHbitmap()); Graphics gra = Graphics.FromImage(image); Font drawFont = new System.Drawing.Font(new FontFamily("SimSun"), 800, FontStyle.Bold); gra.FillRectangle(Brushes.Black, 0, 0, 1000, 1000); for (int i = 1; i <=6; i++) { gra.Clear(Color.Black); gra.DrawString(i.ToString(), drawFont, Brushes.White, new PointF(100, 0)); image.Save("c:\\"+i.ToString()+".jpg"); } gra.Dispose(); image.Dispose(); bmp.Dispose(); } } }
------解决方案--------------------
for(int i=1;i<=600;i++) { Bitmap bmp = new Bitmap(1000,1000); Image image = Image.FromHbitmap(bmp.GetHbitmap()); Graphics gra = Graphics.FromImage(image); Font drawFont=new System.Drawing.Font( new FontFamily( "SimSun"),800,FontStyle.Bold); gra.FillRectangle(Brushes.Black,0,0,1000,1000); gra.DrawString([color=#FF0000]i[/color], drawFont, Brushes.White, new PointF(100,0)); image.Save("c:\\test.jpg"); gra.Dispose(); image.Dispose(); bmp.Dispose(); }
------解决方案--------------------