c#使用GDI+简单绘图
发布时间:2020-12-15 17:53:01 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 // Create the in-memory bitmap where you will draw the image. // This bitmap is 300 pixels wide and 50 pixels high. Bitmap image = new Bitma
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 // Create the in-memory bitmap where you will draw the image. // This bitmap is 300 pixels wide and 50 pixels high. Bitmap image = new Bitmap(300,50); // get the graphics context Graphics g = Graphics.FromImage(image); // Draw a solid white rectangle. // Start from point (1,1). // Make it 298 pixels wide and 48 pixels high. g.FillRectangle(Brushes.White,1,298,48); // load a font and use it to draw a string Font font = new Font("Impact",20,FontStyle.Regular); g.DrawString("This is a test.",font,Brushes.Blue,10,5); // write the image to the output stream. image.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif); // dispose of the context and the bitmap g.Dispose(); image.Dispose(); // Create the in-memory bitmap where you will draw the image. // This bitmap is 450 pixels wide and 100 pixels high. Bitmap image = new Bitmap(450,100); Graphics g = Graphics.FromImage(image); // Ensure high-quality curves. g.SmoothingMode = SmoothingMode.AntiAlias; // Paint the background. g.FillRectangle(Brushes.White,450,100); // Add an ellipse. g.FillEllipse(Brushes.PaleGoldenrod,120,13,300,50); g.DrawEllipse(Pens.Green,299,49); // Draw some text using a fancy font. Font font = new Font("Harrington",FontStyle.Bold); g.DrawString("Oranges are tasty!",Brushes.DarkOrange,150,20); // Add a graphic from a file. System.Drawing.Image orangeImage = System.Drawing.Image.FromFile(Server.MapPath("oranges.gif")); g.DrawImageUnscaled(orangeImage,0); // Render the image to the output stream. image.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); // Clean up. g.Dispose(); image.Dispose(); 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |