private void ExtractMapImage(ImageFormat imageFormat) { Cursor.Current = Cursors.WaitCursor; string fileExtension = Utils.GetFileExtensionFor(imageFormat); string fileName = Path.Combine(Options.OutputPath, $"{Options.MapNames[_currMapId]}.{fileExtension}"); try { Bitmap extract = _currMap.GetImage(0, 0, _currMap.Width >> 3, _currMap.Height >> 3, showStaticsToolStripMenuItem1.Checked); if (showMarkersToolStripMenuItem.Checked) { Graphics g = Graphics.FromImage(extract); foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapId].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.Visible) { o.Draw(g); } } g.Save(); } extract.Save(fileName, imageFormat); } finally { Cursor.Current = Cursors.Default; } MessageBox.Show($"Map saved to {fileName}", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void ExtractMapJpg(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; string path = Options.OutputPath; string name = $"{Options.MapNames[_currMapInt]}.jpg"; string fileName = Path.Combine(path, name); Bitmap extract = _currMap.GetImage(0, 0, _currMap.Width >> 3, _currMap.Height >> 3, showStaticsToolStripMenuItem1.Checked); if (showMarkersToolStripMenuItem.Checked) { Graphics g = Graphics.FromImage(extract); foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapInt].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.Visible) { o.Draw(g); } } g.Save(); } extract.Save(fileName, ImageFormat.Jpeg); Cursor.Current = Cursors.Default; MessageBox.Show($"Map saved to {fileName}", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void OnPaint(object sender, PaintEventArgs e) { _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)(e.ClipRectangle.Width / Zoom + 8) >> 3, (int)(e.ClipRectangle.Height / Zoom + 8) >> 3, showStaticsToolStripMenuItem1.Checked); ZoomMap(ref _map); e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle); if (showCenterCrossToolStripMenuItem1.Checked) { Brush brush = new SolidBrush(Color.FromArgb(180, Color.White)); Pen pen = new Pen(brush); int x = Round(pictureBox.Width / 2); int y = Round(pictureBox.Height / 2); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); pen.Dispose(); brush.Dispose(); } if (showClientCrossToolStripMenuItem.Checked) { if (Client.Running) { if (_clientX > hScrollBar.Value && _clientX < hScrollBar.Value + e.ClipRectangle.Width / Zoom && _clientY > vScrollBar.Value && _clientY < vScrollBar.Value + e.ClipRectangle.Height / Zoom && _clientMap == _currMapInt) { Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow)); Pen pen = new Pen(brush); int x = (int)((_clientX - Round(hScrollBar.Value)) * Zoom); int y = (int)((_clientY - Round(vScrollBar.Value)) * Zoom); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2); pen.Dispose(); brush.Dispose(); } } } if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked) { return; } foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapInt].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.IsVisible(e.ClipRectangle, _currMapInt)) { o.Draw(e.Graphics); } } }
private void OnPaint(object sender, PaintEventArgs e) { if (FormsDesignerHelper.IsInDesignMode()) { return; } if (PreloadWorker.IsBusy) { e.Graphics.DrawString("Preloading map. Please wait...", SystemFonts.DefaultFont, Brushes.Black, 60, 60); return; } _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, showStaticsToolStripMenuItem1.Checked); ZoomMap(ref _map); e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle); if (showCenterCrossToolStripMenuItem1.Checked) { using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.White))) using (Pen pen = new Pen(brush)) { int x = Round(pictureBox.Width / 2); int y = Round(pictureBox.Height / 2); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); } } if (showClientCrossToolStripMenuItem.Checked && Client.Running) { if (_clientX > hScrollBar.Value && _clientX < hScrollBar.Value + (e.ClipRectangle.Width / Zoom) && _clientY > vScrollBar.Value && _clientY < vScrollBar.Value + (e.ClipRectangle.Height / Zoom) && _clientMap == _currMapId) { using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow))) using (Pen pen = new Pen(brush)) { int x = (int)((_clientX - Round(hScrollBar.Value)) * Zoom); int y = (int)((_clientY - Round(vScrollBar.Value)) * Zoom); e.Graphics.DrawLine(pen, x - 4, y, x + 4, y); e.Graphics.DrawLine(pen, x, y - 4, x, y + 4); e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2); } } } if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked) { return; } foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapId].Nodes) { OverlayObject o = (OverlayObject)obj.Tag; if (o.IsVisible(e.ClipRectangle, _currMapId)) { o.Draw(e.Graphics); } } }