protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var _charImage = _character?.ToBitmap(); if (_charImage != null && _bBuffer != null && _gBuffer != null) { _gBuffer.Clear(Color.Transparent); _gBuffer.DrawImage(_charImage, 0, 0, _charImage.Width * Zoom, _charImage.Height * Zoom); if (_showGrid) { DrawGrid(); } /* Kerning updates */ if (_showKerning) { DrawKerning(); } SolidBrush bgBrush = new SolidBrush(SystemColors.ControlDark); e.Graphics.FillRectangle(bgBrush, 0, 0, _charImage.Width * Zoom, GUIDE_SIZE); e.Graphics.FillRectangle(bgBrush, 0, _charImage.Height * Zoom + GUIDE_SIZE, _charImage.Width * Zoom, GUIDE_SIZE); SolidBrush fgBrush = new SolidBrush(Color.Red); Rectangle rect = new Rectangle(2 * Zoom - GUIDE_SIZE, -GUIDE_SIZE, 2 * GUIDE_SIZE, 2 * GUIDE_SIZE); e.Graphics.FillPie(fgBrush, rect, 90, 90); fgBrush = new SolidBrush(Color.Red); rect = new Rectangle(2 * Zoom - GUIDE_SIZE, -GUIDE_SIZE, 2 * GUIDE_SIZE, 2 * GUIDE_SIZE); e.Graphics.FillPie(fgBrush, rect, 90, -90); rect = new Rectangle(2 * Zoom - GUIDE_SIZE, _charImage.Height * Zoom - GUIDE_SIZE, 2 * GUIDE_SIZE, 2 * GUIDE_SIZE); e.Graphics.FillPie(fgBrush, rect, 90, -90); fgBrush = new SolidBrush(Color.Red); rect = new Rectangle(2 * Zoom - GUIDE_SIZE, 0, 2 * GUIDE_SIZE, GUIDE_SIZE); e.Graphics.FillPie(fgBrush, rect, 270, 90); rect = new Rectangle(2 * Zoom - GUIDE_SIZE, _charImage.Height * Zoom + GUIDE_SIZE, 2 * GUIDE_SIZE, GUIDE_SIZE); e.Graphics.FillPie(fgBrush, rect, 270, 90); e.Graphics.DrawImage(_bBuffer, 0, GUIDE_SIZE, _bBuffer.Width, _bBuffer.Height); } }
public static void CopyToClipboard(IZiCharacter character) { var bmp = character.ToBitmap(); if (bmp == null) { return; } // Remove transparency var clip = new Bitmap(bmp.Width, bmp.Height); using (var graphics = Graphics.FromImage(clip)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); graphics.DrawImage(bmp, 0, 0); } Clipboard.SetImage(clip); clip.Dispose(); }
public void Clear() { if (_charGraphics == null) { return; } var _charImage = _character.ToBitmap(); _charGraphics.Clear(Color.Transparent); Character.SetBitmap(_charImage); var ts = (ToolStrip)this.Parent.Parent.Controls["tsCharEditor"]; ts.Items["btnRevertCharacter"].Enabled = true; Invalidate(); Refresh(); }
public static void CopyToClipboard(IZiCharacter character) { var bmp = character.ToBitmap(); if (bmp == null) { return; } // Remove transparency var clip = new Bitmap(bmp.Width, bmp.Height); Color color; using (var graphics = Graphics.FromImage(clip)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); //graphics.DrawImage(bmp, 0, 0); } // Remove ForegroundColor, replace with black for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { color = Color.FromArgb(bmp.GetPixel(x, y).A, Color.Black); clip.SetPixel(x, y, color); } } var clip2 = new Bitmap(bmp.Width, bmp.Height); using (var graphics = Graphics.FromImage(clip2)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); graphics.DrawImage(clip, 0, 0); } Clipboard.SetImage(clip2); clip.Dispose(); clip2.Dispose(); }