如何在C#中绘制图像并将其显示在网页上? [英] how to draw image in c# and show it to a web page?

查看:68
本文介绍了如何在C#中绘制图像并将其显示在网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码无法正常工作.我不知道我在哪里错.


I have used following code it did not work. I do not know where i am wrong.


Response.Clear();
       int height =500;
       int width = 500;
       Random r = new Random();
       int x = r.Next(500);

       Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
       Graphics g = Graphics.FromImage(bmp);
       g.SmoothingMode = SmoothingMode.AntiAlias;
       //g.TextRenderingHint = TextRenderingHint.AntiAlias;
       g.Clear(Color.Green);
       System.Threading.Thread.Sleep(5000);
       System.Drawing.Pen p = new System.Drawing.Pen(System.Drawing.Color.Red);

       System.Drawing.Pen p1 = new System.Drawing.Pen(System.Drawing.Color.Blue);

       System.Drawing.Brush background=new System.Drawing.SolidBrush(System.Drawing.Color.Violet);

       System.Drawing.Brush background1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red);

       //g.FillEllipse(background, 0, 0, 100, 100);

       //g.FillPie(background, 100, 100, 100, 100, 0, 90);

     //  g.FillRectangle(background, 0, 100, 200, 50);

      // g.DrawRectangle(p1, 0, 0, 300, 300);

       g.DrawString("maneesh", new Font("Arial", 12, FontStyle.Italic), background1, new PointF(100, 50));
      // g.DrawBezier(p,new PointF(0, 0),new PointF(10, 70),new PointF(100, 100),new PointF(200, 250));
       //
       bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
     //  bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
       g.Dispose();
       bmp.Dispose();
       Response.End();

推荐答案

Maneesh,
请检查这篇文章.
> http://stackoverflow.com/questions/2871298/using-drawstring- to-draw-text-with-border [ ^ ]
Hi Maneesh,
Please check this post.
http://stackoverflow.com/questions/2871298/using-drawstring-to-draw-text-with-no-border[^]


这篇关于如何在C#中绘制图像并将其显示在网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆