图片

context.Response.ContentType = "image/jpeg";

    //画纸
    using (Bitmap bitmap = new Bitmap(120, 80))
    { 
        //画笔
        using (Graphics g = Graphics.FromImage(bitmap))
        {
            g.FillRectangle(Brushes.Black, 0, 0, bitmap.Width, bitmap.Height);
            g.FillRectangle(Brushes.White, 1, 1, bitmap.Width - 2, bitmap.Height - 2);
            
            
            g.DrawString("挨踢教瘦", new Font("微软雅黑", 20), Brushes.Red, 5, 5);

            //把图片输出给浏览器
            bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }

posted on 2015-02-11 22:28  木屐  阅读(109)  评论(0编辑  收藏  举报

导航