- Timestamp:
- 09/11/13 14:34:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs
r9520 r9946 68 68 Width = 305; 69 69 Height = 625; 70 } finally { SuppressEvents = false; } 70 } 71 finally { SuppressEvents = false; } 71 72 #endregion 72 73 } … … 93 94 if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "6"; 94 95 else legendFontSizeComboBox.Text = workingChart.Legends[0].Font.SizeInPoints.ToString(); 95 } finally { 96 } 97 finally { 96 98 SuppressEvents = false; 97 99 } … … 209 211 } 210 212 } 211 } finally { SuppressEvents = false; } 213 } 214 finally { SuppressEvents = false; } 212 215 base.OnShown(e); 213 216 … … 438 441 float height; 439 442 GetImageParameters(out dpi, out width, out height); 440 441 443 var image = new Bitmap((int)Math.Round(width), (int)Math.Round(height)); 442 444 image.SetResolution(dpi, dpi); 443 using (var graphics = Graphics.FromImage(image)) {444 workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height));445 }446 447 445 if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim(); 448 446 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 449 447 var format = ImageFormat.Bmp; 450 448 var filename = saveFileDialog.FileName.ToLower(); 451 if (filename.EndsWith("jpg")) { 452 format = ImageFormat.Jpeg; 453 } else if (filename.EndsWith("emf")) { 454 format = ImageFormat.Emf; 455 } else if (filename.EndsWith("gif")) { 456 format = ImageFormat.Gif; 457 } else if (filename.EndsWith("png")) { 458 format = ImageFormat.Png; 459 } else if (filename.EndsWith("tif")) { 460 format = ImageFormat.Tiff; 461 } 462 image.Save(saveFileDialog.FileName, format); 463 } 464 449 if (filename.EndsWith("emf")) { 450 using (var graphics = Graphics.FromImage(image)) { 451 var metafile = new Metafile(filename, graphics.GetHdc()); 452 graphics.ReleaseHdc(); 453 using (var g = Graphics.FromImage(metafile)) { 454 workingChart.Printing.PrintPaint(g, new Rectangle(0, 0, image.Width, image.Height)); 455 } 456 metafile.Dispose(); 457 } 458 } else { 459 using (var graphics = Graphics.FromImage(image)) { 460 workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height)); 461 } 462 if (filename.EndsWith("jpg")) { 463 format = ImageFormat.Jpeg; 464 } else if (filename.EndsWith("gif")) { 465 format = ImageFormat.Gif; 466 } else if (filename.EndsWith("png")) { 467 format = ImageFormat.Png; 468 } else if (filename.EndsWith("tif")) { 469 format = ImageFormat.Tiff; 470 } 471 image.Save(saveFileDialog.FileName, format); 472 } 473 } 465 474 image.Dispose(); 466 467 475 Cleanup(); 468 476 }
Note: See TracChangeset
for help on using the changeset viewer.