asp.net C\#태극 도 를 그 리 는 방법
완제품 도 는 다음 과 같다.
 html 페이지:
설정 주의:
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 white = new SolidBrush(Color.White);  
        graphics.FillRectangle(white, new Rectangle(0, 0, imgWidth, imgWidth));
        Brush blue = new SolidBrush(Color.Blue);//        
        Brush red = new SolidBrush(Color.Red);//       
        //          
        graphics.FillPie(blue, 0, 0, imgWidth, imgWidth, 0, 360);  
  
        //       (    )  
        GraphicsPath redPath = new GraphicsPath();//       
        redPath.AddArc(0, 0, imgWidth, imgWidth, 0, -180);  
        redPath.AddArc(0, headDiameter / 2, headDiameter, headDiameter, 0, -180);  
        redPath.AddArc(headDiameter, headDiameter / 2, headDiameter, headDiameter, 0, 180);
        //        
        graphics.FillPath(red, redPath);
        //        
        graphics.FillPie(red, new Rectangle(headDiameter / 2 - eyeRadius, headDiameter - eyeRadius, eyeRadius * 2, eyeRadius * 2), 0, 360); 
        //        
        graphics.FillPie(blue, new Rectangle(headDiameter + headDiameter / 2 - eyeRadius, headDiameter - eyeRadius, eyeRadius * 2, eyeRadius * 2), 0, 360); 
        graphics.Dispose(); 
        //   Response     ,      
        //image.Save(Response.OutputStream, ImageFormat.Jpeg); 
        //          
        ImageCodecInfo myImageCodecInfo = GetEncoder(ImageFormat.Jpeg);  
        myEncoder = Encoder.Quality;  
        myEncoderParameters = new EncoderParameters(1);  
        //        
        myEncoderParameter = new EncoderParameter(myEncoder, 100L);  
        myEncoderParameters.Param[0] = myEncoderParameter;  
  
        //          
        image.Save(Response.OutputStream, myImageCodecInfo, myEncoderParameters);  
    }  
    private static ImageCodecInfo GetEncoder(ImageFormat format)  
    {  
        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();  
  
        foreach (ImageCodecInfo codec in codecs)  
        {  
            if (codec.FormatID == format.Guid)  
            {  
                return codec;  
            }  
        }  
        return null;  
    }  
}
본 고 에서 말 한 것 이 여러분 의 C\#프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
작업 중 문제 해결 - (win 2003 asp. net) Session 과 페이지 전송 방법 으로 해결 방안 을 정상적으로 사용 할 수 없습니다.또한 F 는 처음에 우리 의 BP & IT 프로젝트 팀 이 Forms 폼 검증 을 사용 했다 고 판단 할 수 있 습 니 다. 페이지 를 뛰 어 넘 는 것 은http://hr.bingjun.cc/MyTask/MyTas...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.