[C#]如何利用 GDI+ 進行繪製並存檔

包含 c#, asp.net, vb.net, delphi.net 等 .net framework 的開發討論區
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[C#]如何利用 GDI+ 進行繪製並存檔

文章 tim »

使用 Bitmap 進行, 配合 Graphics 的 FromImage 來取得繪製的控制, 之後再進行存檔, 指定格式即可!

代碼: 選擇全部

     
        private void button1_Click(object sender, System.EventArgs e) 
        { 
          Bitmap bmp = new Bitmap(100, 100);       
          Graphics g = Graphics.FromImage(bmp);       
          Pen p = new System.Drawing.Pen(System.Drawing.Color.Red); 
          g.DrawLine(p, 10, 10, 20, 20); 
     
          Font drawFont = new Font("Arial", 9); 
          SolidBrush drawBrush = new SolidBrush(Color.Blue); 
     
          g.DrawString("test string", drawFont, drawBrush, 10, 40); 
          bmp.Save("c:\1.bmp", System.Drawing.Imaging.Imageformat.Bmp);       
        } 

附件為輸出的結果!!
16_11.gif
16_11.gif (1.07 KiB) 已瀏覽 2794 次
多多留言, 整理文章, 把經驗累積下來.....
回覆文章