c# gdi鎬庝箞浣跨敤
C# GDI(Graphics Device Interface)鏄竴绉嶇敤浜庣粯鍒跺浘褰㈠拰鍥惧儚鐨凙PI銆備笅闈㈡槸浣跨敤C# GDI缁樺埗鍥惧舰鐨勪竴浜涘熀鏈楠わ細
- 寮曞叆鍛藉悕绌洪棿锛?/li>
using System.Drawing;
using System.Drawing.Drawing2D;
- 鍒涘缓涓€涓狦raphics瀵硅薄锛?/li>
Graphics graphics = this.CreateGraphics();
- 鍒涘缓涓€涓敾绗旓紙Pen锛夋垨鍒峰瓙锛圔rush锛夊璞★紝鐢ㄤ簬鎸囧畾缁樺埗鐨勯鑹插拰鏍峰紡锛?/li>
Pen pen = new Pen(Color.Red, 2); // 鍒涘缓绾㈣壊鐢荤瑪锛岀嚎瀹戒负2涓儚绱?/span>
Brush brush = new SolidBrush(Color.Blue); // 鍒涘缓钃濊壊鍒峰瓙
- 缁樺埗鍥惧舰锛?/li>
graphics.DrawLine(pen, startPoint, endPoint); // 缁樺埗鐩寸嚎
graphics.DrawRectangle(pen, x, y, width, height); // 缁樺埗鐭╁舰
graphics.DrawEllipse(pen, x, y, width, height); // 缁樺埗妞渾
graphics.FillRectangle(brush, x, y, width, height); // 濉厖鐭╁舰
graphics.FillEllipse(brush, x, y, width, height); // 濉厖妞渾
- 閲婃斁璧勬簮锛?/li>
pen.Dispose();
brush.Dispose();
graphics.Dispose();
娉ㄦ剰锛氫互涓婁唬鐮佺墖娈典粎涓虹ず渚嬶紝瀹為檯浣跨敤鏃堕渶瑕佹牴鎹叿浣撻渶姹傝繘琛岃皟鏁淬€?/p>
相关问答