打印本文 打印本文 关闭窗口 关闭窗口
Asp.net中使用GDI+繪製圖形
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2976  更新时间:2009/4/23 10:40:06  文章录入:mintao  责任编辑:mintao
                // 將繪製的圖像以 Gif 的格式保存到當前頁面響應的輸出流中

                bitmap.Save(this.Response.OutputStream,ImageFormat.Gif);

           }

          

           /// <summary>

           /// 對即將要被繪製的位圖(可想象為一塊畫佈)進行初始動作

           /// </summary>

           private void Init_Bitmap()

           {

                bitmap = new Bitmap(400,200);

                graphics = Graphics.FromImage(bitmap);

                graphics.Clear(Color.White);

 

                graphics.DrawString("X 公司上半年銷售情況",new Font("新細明体",16,FontStyle.Underline),Brushes.Black,new PointF(5,5));

           }

 

           #region Web Form 設計工具產生的程式碼

           override protected void OnInit(EventArgs e)

           {

                //

                // CODEGEN: 此為 ASP.NET Web Form 設計工具所需的呼叫。

                //

                InitializeComponent();

                base.OnInit(e);

           }

          

           /// <summary>

           /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改

           /// 這個方法的內容。

           /// </summary>

           private void InitializeComponent()

           {   

                this.Load += new System.EventHandler(this.Page_Load);

 

           }

           #endregion

          

           /// <summary>

           /// 在畫佈上面繪製矩形

           /// </summary>

           private void Draw_Rectangle()

           {

                int i;

                PointF symbolLeg = new PointF(335,20);

                PointF   descLeg = new PointF(360,16);

               

                for (i = 0; i < arrValueNames.Length; i++)

                {

                     graphics.FillRectangle(new SolidBrush(GetColor(i)),symbolLeg.X,symbolLeg.Y,20,10);

                     graphics.DrawRectangle(Pens.Black,symbolLeg.X,symbolLeg.Y,20,10);

                     graphics.DrawString(arrValueNames[i].ToString(),new Font("新細明体",8),Brushes.Black,descLeg);

 

                      symbolLeg.Y += 15;

                     descLeg.Y   += 16;

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口