在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
本文实例讲述了asp.net实现C#绘制太极图的方法。分享给大家供大家参考。具体如下: 成品图如下所示: html页面: 注意设置: 复制代码 代码如下: ContentType="Image/Jpeg"
复制代码 代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TaiJiTu.aspx.cs" Inherits="TaiJiTu" ContentType="Image/Jpeg" %>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body> </html> 后台代码: 复制代码 代码如下: using System;
using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; public partial class TaiJiTu : System.Web.UI.Page { private Encoder myEncoder; private EncoderParameter myEncoderParameter; private EncoderParameters myEncoderParameters; protected void Page_Load(object sender, EventArgs e) { int imgWidth = 400; //图象尺寸 int eyeRadius = imgWidth / 20; //鱼眼半径 int headDiameter = imgWidth / 2; //鱼头直径 Bitmap image = new Bitmap(imgWidth, imgWidth); image.SetResolution(300, 300); Graphics graphics = Graphics.FromImage(image); //设置图像质量 graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; //底色填充为白色 Brush blue = new SolidBrush(Color.Blue);//定义蓝色笔刷 //整个圆形填充蓝色 graphics.Dispose(); //写入到Response输出流中去,普通质量 //修改图片保存质量 希望本文所述对大家的C#程序设计有所帮助。 |
请发表评论