C# GraphicsPath.Flatten 方法將曲線路徑近似為直線段:容差參數控制精度與效能
程式碼範例 private void Form11_Paint(object sender, PaintEventArgs e) { Matrix ma
C# 使用 Matrix.Translate 位移座標原點:在相同邏輯座標下繪製不同螢幕位置的圖形
程式碼範例 void DrawLabelRect(Graphics g, string label) { Rectangle rect = new Re
C# 在記憶體位圖上繪製文字並儲存為 PNG 檔案:Graphics.DrawString 完整實作流程
完整步驟 private void button1_Click(object sender, EventArgs e) { Rectangle rect
C# GDI+ Matrix 縮放與平移複合轉換:操作順序對座標系統的影響實測
程式碼範例 private void Form9_Paint(object sender, PaintEventArgs e) { Rectangle
C# 使用 Bitmap.RotateFlip 實現圖片旋轉 90 度與水平翻轉的最簡單範例
核心程式碼 using (Bitmap bmp = new Bitmap(@d:/我的文件/桌面/ico/watermark.bmp)) { Graph
C# Bitmap.GetHicon 轉換為 Icon 並設定視窗圖示
核心方法 Bitmap bmp = new Bitmap(icon.png); IntPtr hIcon = bmp.GetHicon(); // 取得 HI
C# 螢幕截圖/視窗截圖 完整實作 (CopyFromScreen/DrawToBitmap)
方法一:全螢幕/指定區域截圖 (CopyFromScreen) using System; using System.Drawing; using Syste
C# Matrix.RotateAt 文字/圖形任意角度旋轉繪製
核心方法 // 以指定中心點旋轉 Matrix m = new Matrix(); m.RotateAt(angleDegrees, centerPoint)
C# DrawCurve 繪製 Cardinal Spline 平滑曲線
DrawCurve 參數說明 // 基本 g.DrawCurve(pen, points); // tension=0.5 // 指定張力 g.DrawCu
C# 以 Brush 建立 Pen (漸層/紋理/斜紋畫筆)
核心概念 Pen 建構子接受 Brush 參數,即可使用任何筆刷 (SolidBrush/LinearGradientBrush/TextureBrush/Ha
C# ImageAttributes 色彩重對應 (ColorMap) 實作圖片重新著色
核心類別 ColorMap:定義舊顏色 → 新顏色對應。 ImageAttributes:攜帶 ColorMap[]、ColorMatrix、Gamma 等色
C# Paint 事件正確處理 (Invalidate/Update/雙緩衝/ResizeRedraw)
Paint 事件機制 Windows 發送 WM_PAINT 訊息時觸發。 Invalidate() 標記區域需重繪,排入訊息佇列,**非立即執行**。 Up
C# DrawEllipse 繪製橢圓/圓 完整教學
基本方法 // 以外接矩形定義 g.DrawEllipse(pen, x, y, width, height); g.DrawEllipse(pen, rec
C# GraphicsPath 繪製圓角矩形/任意路徑圖形
GraphicsPath 基本圖形方法 方法說明 AddLine直線段 AddArc圓弧 (矩形範圍、起始角、掃描角) AddRectangle矩形 Add
C# LinearGradientBrush 線性漸層筆刷完整教學 (多色/三角/鐘形)
核心建構子 // 兩點定義漸層方向 LinearGradientBrush brush = new LinearGradientBrush( Poin
C# ContextMenuStrip 右鍵選單完整實作 (剪貼簿/動態項目/快捷鍵)
基本建立與綁定 textBox.SelectAll()).ShortcutKeys = Keys.Control | Keys.A; textBox.Con
C# Pen.CustomEndCap 自訂線帽 (箭頭/圖形/調整大小)
兩種自訂線帽方式 類別用途特色 AdjustableArrowCap可調整大小的箭頭寬度、高度、填充/空心、中間凹陷 CustomLineCap完全自訂圖形
C# Pen.DashPattern 自訂虛線樣式完整教學
DashPattern 陣列格式 float[] dashPattern = { on1, off1, on2, off2, ... } 單位:**筆寬的倍數