예제 #1
0
        /// <summary>
        /// Saves the graph into a stream.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="stream">The stream to render inot.</param>
        /// <param name="backbrush1">First brush used to fill the background of the image (normally used with 24bbp bitmap formats to make the background opaque. Can be <c>null</c>.</param>
        /// <param name="backbrush2">Second brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        /// <param name="sourceDpiResolution">Resolution at which the graph document is rendered into a bitmap.</param>
        /// <param name="destinationDpiResolution">Resolution which is assigned to the bitmap. This determines the physical size of the bitmap.</param>
        /// <returns>The pixel dimensions of the image if the rendering was successful. The tuple (0,0) is returned if the rendering was unsuccessful, e.g. if no exporter was available.</returns>
        public static (int PixelsX, int PixelsY) RenderToStream(this GraphDocument doc, System.IO.Stream stream, Altaxo.Graph.Gdi.BrushX backbrush1, Altaxo.Graph.Gdi.BrushX backbrush2, PixelFormat pixelformat, double sourceDpiResolution, double destinationDpiResolution)
        {
            var exportOptions = new Altaxo.Graph.Gdi.GraphExportOptions();

            exportOptions.TrySetImageAndPixelFormat(ImageFormat.Png, PixelFormat.Format32bppArgb);
            exportOptions.SourceDpiResolution      = sourceDpiResolution;
            exportOptions.DestinationDpiResolution = destinationDpiResolution;
            exportOptions.BackgroundBrush          = backbrush1;
            return(RenderToStream(doc, stream, exportOptions));
        }
예제 #2
0
 /// <inheritdoc/>
 public (int PixelsX, int PixelsY) ExportAsImageToStream(IProjectItem item, GraphExportOptions options, Stream toStream)
 {
     if (item is GraphDocument doc)
     {
         return(GraphDocumentExportActions.RenderToStream(doc, toStream, options));
     }
     else
     {
         throw new ArgumentException("Item have to be of type " + typeof(GraphDocument).ToString(), nameof(item));
     }
 }
예제 #3
0
		/// <summary>Shows the dialog to choose the graph export options, and then the multi file export dialog.</summary>
		/// <param name="documents">List with graph documents to export.</param>
		public static void ShowExportMultipleGraphsDialogAndExportOptions(IEnumerable<Graph.Gdi.GraphDocument> documents)
		{
			object resopt = _graphExportOptionsToFile;
			if (Current.Gui.ShowDialog(ref resopt, "Choose export options"))
			{
				_graphExportOptionsToFile = (GraphExportOptions)resopt;
			}
			else
			{
				return;
			}

			ShowExportMultipleGraphsDialog(documents);
		}
예제 #4
0
        /// <summary>
        /// Renders the graph document as bitmap with default PixelFormat.Format32bppArgb.
        /// </summary>
        /// <param name="doc">The graph document used.</param>
        /// <param name="exportOptions">The clipboard export options.</param>
        /// <param name="pixelFormat">The pixel format for the bitmap. Default is PixelFormat.Format32bppArgb.</param>
        /// <returns>The rendered enhanced metafile.</returns>
        public static Bitmap RenderAsBitmap(GraphDocument doc, EmbeddedObjectRenderingOptions exportOptions, PixelFormat pixelFormat = PixelFormat.Format32bppArgb)
        {
            BrushX opaqueGround = null;

            if (!GraphExportOptions.HasPixelFormatAlphaChannel(pixelFormat))
            {
                opaqueGround = new BrushX(exportOptions.BackgroundColorForFormatsWithoutAlphaChannel);
            }

            var result = RenderAsBitmap(doc, opaqueGround, exportOptions.BackgroundBrush, pixelFormat, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.OutputScalingFactor);

            if (null != opaqueGround)
            {
                opaqueGround.Dispose();
            }

            return(result);
        }
예제 #5
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var s = null != o ? (ClipboardRenderingOptions)o : new ClipboardRenderingOptions();

                var oldBase = new GraphExportOptions();

                info.GetBaseValueEmbedded(oldBase, typeof(GraphExportOptions), parent);
                var clipboardFormat = (GraphCopyPageClipboardFormat)info.GetEnum("ClipboardFormat", typeof(GraphCopyPageClipboardFormat));

                s.SourceDpiResolution              = oldBase.SourceDpiResolution;
                s.OutputScalingFactor              = oldBase.SourceDpiResolution / oldBase.DestinationDpiResolution;
                s.BackgroundBrush                  = oldBase.BackgroundBrush;
                s._renderDropFileImageFormat       = oldBase.ImageFormat;
                s._renderDropFileBitmapPixelFormat = oldBase.PixelFormat;

                s.RenderDropFile       = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsDropDownList);
                s.RenderEmbeddedObject = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsEmbeddedObject);
                s.RenderLinkedObject   = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsLinkedObject);
                s.RenderEnhancedMetafileAsVectorFormat = !clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsNativeWrappedInEnhancedMetafile);

                return(s);
            }
예제 #6
0
 public static Bitmap RenderAsBitmap(this GraphDocument doc, GraphExportOptions options)
 {
     return(RenderAsBitmap(doc, options.BackgroundBrush, options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution));
 }
예제 #7
0
		public GraphExportOptions(GraphExportOptions from)
		{
			CopyFrom(from);
		}
예제 #8
0
		public static void ShowFileExportDialog(this GraphDocument doc, GraphExportOptions graphExportOptions)
		{
			var saveOptions = new Altaxo.Gui.SaveFileOptions();
			var list = GetFileFilterString(graphExportOptions.ImageFormat);
			foreach (var entry in list)
				saveOptions.AddFilter(entry.Key, entry.Value);
			saveOptions.FilterIndex = 0;
			saveOptions.RestoreDirectory = true;

			if (Current.Gui.ShowSaveFileDialog(saveOptions))
			{
				using (Stream myStream = new FileStream(saveOptions.FileName, FileMode.Create, FileAccess.Write, FileShare.Read))
				{
					doc.RenderToStream(myStream, graphExportOptions);
					myStream.Close();
				} // end openfile ok
			} // end dlgresult ok
		}
예제 #9
0
			public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				var s = null != o ? (ClipboardRenderingOptions)o : new ClipboardRenderingOptions();

				var oldBase = new GraphExportOptions();
				info.GetBaseValueEmbedded(oldBase, typeof(GraphExportOptions), parent);
				var clipboardFormat = (GraphCopyPageClipboardFormat)info.GetEnum("ClipboardFormat", typeof(GraphCopyPageClipboardFormat));

				s.SourceDpiResolution = oldBase.SourceDpiResolution;
				s.OutputScalingFactor = oldBase.SourceDpiResolution / oldBase.DestinationDpiResolution;
				s.BackgroundBrush = oldBase.BackgroundBrush;
				s._renderDropFileImageFormat = oldBase.ImageFormat;
				s._renderDropFileBitmapPixelFormat = oldBase.PixelFormat;

				s.RenderDropFile = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsDropDownList);
				s.RenderEmbeddedObject = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsEmbeddedObject);
				s.RenderLinkedObject = clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsLinkedObject);
				s.RenderEnhancedMetafileAsVectorFormat = !clipboardFormat.HasFlag(GraphCopyPageClipboardFormat.AsNativeWrappedInEnhancedMetafile);

				return s;
			}
예제 #10
0
		/// <summary>
		/// Saves the graph as an bitmap file and returns the bitmap.
		/// </summary>
		/// <param name="doc">The graph document to export.</param>
		/// <param name="backbrush1">First brush used to fill the background of the image (normally used with 24bbp bitmap formats to make the background opaque. Can be <c>null</c>.</param>
		/// <param name="backbrush2">Second brush used to fill the background of the image. Can be <c>null</c>.</param>
		/// <param name="pixelformat">Specify the pixelformat here.</param>
		/// <param name="sourceDpiResolution">Resolution at which the graph document is rendered into a bitmap.</param>
		/// <param name="destinationDpiResolution">Resolution which is assigned to the bitmap. This determines the physical size of the bitmap.</param>
		/// <returns>The saved bitmap. You should call Dispose when you no longer need the bitmap.</returns>
		public static Bitmap RenderAsBitmap(this GraphDocument doc, Altaxo.Graph.Gdi.BrushX backbrush1, Altaxo.Graph.Gdi.BrushX backbrush2, PixelFormat pixelformat, double sourceDpiResolution, double destinationDpiResolution)
		{
			var imageExporter = Current.ProjectService.GetProjectItemImageExporter(doc);
			if (null == imageExporter)
				return null;

			Bitmap bitmap = null;

			using (var memStream = new System.IO.MemoryStream())
			{
				var exportOptions = new Altaxo.Graph.Gdi.GraphExportOptions();
				exportOptions.TrySetImageAndPixelFormat(ImageFormat.Png, PixelFormat.Format32bppArgb);
				exportOptions.SourceDpiResolution = sourceDpiResolution;
				exportOptions.DestinationDpiResolution = destinationDpiResolution;
				exportOptions.BackgroundBrush = backbrush1;
				imageExporter.ExportAsImageToStream(doc, exportOptions, memStream);

				memStream.Seek(0, System.IO.SeekOrigin.Begin);
				bitmap = (Bitmap)Bitmap.FromStream(memStream);
			}

			int bmpWidth = bitmap.Width;
			int bmpHeight = bitmap.Height;
			/*
			double outputScaling = sourceDpiResolution / destinationDpiResolution;
			bitmap.SetResolution((float)(bmpWidth / (outputScaling * doc.Size.X / 72)), (float)(bmpHeight / (outputScaling * doc.Size.Y / 72)));

			using (Graphics grfx = Graphics.FromImage(bitmap))
			{
				// Set everything to high quality
				grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
				grfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

				// 2014-10-10 Setting InterpolationMode to HighQualityBicubic and PixelOffsetMode to HighQuality
				// causes problems when rendering small bitmaps (at a large magnification, for instance the density image legend):
				// the resulting image seems a litte soft, the colors somehow distorted, so I decided not to use them here any more

				//		grfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
				//		grfx.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

				grfx.PageUnit = GraphicsUnit.Point;
				grfx.ScaleTransform((float)outputScaling, (float)outputScaling);
				grfx.SetClip(new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));

				if (null != backbrush1)
				{
					backbrush1.SetEnvironment(new RectangleD2D(0, 0, doc.Size.X, doc.Size.Y), sourceDpiResolution);
					grfx.FillRectangle(backbrush1, new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
				}

				if (null != backbrush2)
				{
					backbrush2.SetEnvironment(new RectangleD2D(0, 0, doc.Size.X, doc.Size.Y), sourceDpiResolution);
					grfx.FillRectangle(backbrush2, new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
				}
			}
			*/

			bitmap.SetResolution((float)destinationDpiResolution, (float)destinationDpiResolution);

			return bitmap;
		}
예제 #11
0
		public static void ShowFileExportTiffDialog(this GraphDocument doc)
		{
			var opt = new GraphExportOptions();
			opt.TrySetImageAndPixelFormat(ImageFormat.Tiff, PixelFormat.Format32bppArgb);
			opt.SourceDpiResolution = 300;
			opt.DestinationDpiResolution = 300;
			ShowFileExportDialog(doc, opt);
		}
예제 #12
0
		public static void ShowFileExportSpecificDialog(this GraphDocument doc)
		{
			object resopt = _graphExportOptionsToFile;
			if (Current.Gui.ShowDialog(ref resopt, "Choose export options"))
			{
				_graphExportOptionsToFile = (GraphExportOptions)resopt;
			}
			else
			{
				return;
			}
			ShowFileExportDialog(doc, _graphExportOptionsToFile);
		}
예제 #13
0
        public static (int pixelsX, int pixelsY) RenderToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions options)
        {
            (int pixelsX, int pixelsY)result;

            if (options.ImageFormat == ImageFormat.Wmf || options.ImageFormat == ImageFormat.Emf)
            {
                result = RenderAsEnhancedMetafileVectorFormatToStream(doc, stream, options);
            }
            else
            {
                result = doc.RenderAsBitmapToStream(stream, options);
            }

            return(result);
        }
예제 #14
0
 /// <summary>
 /// Renders the graph document as enhanced metafile image in vector format with the options given in <paramref name="exportOptions"/>
 /// </summary>
 /// <param name="doc">The graph document used.</param>
 /// <param name="exportOptions">The clipboard export options.</param>
 /// <param name="stream">Optional: if given, the metafile is additionally rendered into the stream.</param>
 /// <returns>The rendered enhanced metafile.</returns>
 public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, GraphExportOptions exportOptions, System.IO.Stream stream = null)
 {
     return(RenderAsEnhancedMetafileVectorFormat(doc, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.DestinationDpiResolution, exportOptions.BackgroundBrush, exportOptions.PixelFormat, stream));
 }
예제 #15
0
		public static void RenderAsBitmapToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions options)
		{
			RenderAsBitmapToStream(doc, stream, options.ImageFormat, options.GetBrushOrDefaultBrush(), options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution);
		}
예제 #16
0
		public static void RenderAsBitmapToFile(this GraphDocument doc, string filename, GraphExportOptions options)
		{
			RenderAsBitmapToFile(doc, filename, options.ImageFormat, options.BackgroundBrush, options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution);
		}
예제 #17
0
		public static Bitmap RenderAsBitmap(this GraphDocument doc, GraphExportOptions options)
		{
			return RenderAsBitmap(doc, options.BackgroundBrush, options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution);
		}
예제 #18
0
		public static void RenderToFile(this GraphDocument doc, string filename, GraphExportOptions options)
		{
			using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
			{
				RenderToStream(doc, str, options);
				str.Close();
			}
		}
예제 #19
0
		public static void RenderToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions options)
		{
			if (options.ImageFormat == ImageFormat.Wmf || options.ImageFormat == ImageFormat.Emf)
				RenderAsEnhancedMetafileVectorFormatToStream(doc, stream, options);
			else
				doc.RenderAsBitmapToStream(stream, options);
		}
예제 #20
0
 /// <summary>
 /// Saves the graph as an bitmap file into the stream using the default pixelformat 32bppArgb.<paramref name="stream"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="stream">The stream to save the metafile into.</param>
 /// <param name="options">The export options.</param>
 /// <returns>The dimensions of the bitmap in pixels.</returns>
 public static (int pixelX, int pixelY) RenderAsBitmapToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions options)
 {
     return(RenderAsBitmapToStream(doc, stream, options.ImageFormat, options.GetBrushOrDefaultBrush(), options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution));
 }
예제 #21
0
        public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, GraphExportOptions options, string filename)
        {
            Metafile mf;

            using (System.IO.Stream stream = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
            {
                mf = RenderAsEnhancedMetafileVectorFormat(doc, options, stream);
                stream.Close();
            }
            return(mf);
        }
예제 #22
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/> using the default
 /// pixel format 32bppArgb.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="options">The export options</param>
 /// <returns>The dimensions of the bitmap in pixels.</returns>
 public static (int pixelX, int pixelY) RenderAsBitmapToFile(this GraphDocument doc, string filename, GraphExportOptions options)
 {
     return(RenderAsBitmapToFile(doc, filename, options.ImageFormat, options.BackgroundBrush, options.PixelFormat, options.SourceDpiResolution, options.DestinationDpiResolution));
 }
예제 #23
0
		public static void ShowFileExportMetafileDialog(this GraphDocument doc)
		{
			var opt = new GraphExportOptions();
			opt.TrySetImageAndPixelFormat(ImageFormat.Emf, PixelFormat.Format32bppArgb);
			ShowFileExportDialog(doc, opt);
		}
예제 #24
0
 public static (int pixelsX, int pixelsY) RenderToFile(this GraphDocument doc, string filename, GraphExportOptions options)
 {
     using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
     {
         var result = RenderToStream(doc, str, options);
         str.Close();
         return(result);
     }
 }
예제 #25
0
		/// <summary>
		/// Renders the graph document as enhanced metafile image in vector format with the options given in <paramref name="exportOptions"/>
		/// </summary>
		/// <param name="doc">The graph document used.</param>
		/// <param name="exportOptions">The clipboard export options.</param>
		/// <param name="stream">Optional: if given, the metafile is additionally rendered into the stream.</param>
		/// <returns>The rendered enhanced metafile.</returns>
		public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, GraphExportOptions exportOptions, System.IO.Stream stream = null)
		{
			return RenderAsEnhancedMetafileVectorFormat(doc, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.DestinationDpiResolution, exportOptions.BackgroundBrush, exportOptions.PixelFormat, stream);
		}
예제 #26
0
 /// <summary>
 /// Renders the graph document as enhanced metafile image in vector format with the options given in <paramref name="exportOptions"/>
 /// </summary>
 /// <param name="doc">The graph document used.</param>
 /// <param name="stream">The stream to which to render the metafile.</param>
 /// <param name="exportOptions">The clipboard export options.</param>
 public static (int pixelsX, int pixelsY) RenderAsEnhancedMetafileVectorFormatToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions exportOptions)
 {
     return(RenderAsEnhancedMetafileVectorFormatToStream(doc, stream, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.DestinationDpiResolution, exportOptions.BackgroundBrush, exportOptions.PixelFormat));
 }
예제 #27
0
        /// <summary>
        /// Saves the graph as into a stream.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="stream">The stream to render inot.</param>
        /// <param name="exportOptions">The export options to use.</param>
        /// <returns>The dimensions of the image in pixels). If the rendering was unsuccessful, e.g. because no exporter was available, the tuple (0,0) is returned.</returns>
        public static (int pixelsX, int pixelsY) RenderToStream(this GraphDocument doc, System.IO.Stream stream, Altaxo.Graph.Gdi.GraphExportOptions exportOptions)
        {
            var imageExporter = Current.ProjectService.GetProjectItemImageExporter(doc);

            if (null == imageExporter)
            {
                return(0, 0);
            }
            else
            {
                return(imageExporter.ExportAsImageToStream(doc, exportOptions, stream));
            }
        }
예제 #28
0
		/// <summary>
		/// Renders the graph document as enhanced metafile image in vector format with the options given in <paramref name="exportOptions"/>
		/// </summary>
		/// <param name="doc">The graph document used.</param>
		/// <param name="stream">The stream to which to render the metafile.</param>
		/// <param name="exportOptions">The clipboard export options.</param>
		public static void RenderAsEnhancedMetafileVectorFormatToStream(this GraphDocument doc, System.IO.Stream stream, GraphExportOptions exportOptions)
		{
			RenderAsEnhancedMetafileVectorFormatToStream(doc, stream, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.DestinationDpiResolution, exportOptions.BackgroundBrush, exportOptions.PixelFormat);
		}
예제 #29
0
 public GraphExportOptions(GraphExportOptions from)
 {
     CopyFrom(from);
 }
예제 #30
0
        /// <summary>
        /// Saves the graph as an bitmap file and returns the bitmap.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="backbrush1">First brush used to fill the background of the image (normally used with 24bbp bitmap formats to make the background opaque. Can be <c>null</c>.</param>
        /// <param name="backbrush2">Second brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        /// <param name="sourceDpiResolution">Resolution at which the graph document is rendered into a bitmap.</param>
        /// <param name="destinationDpiResolution">Resolution which is assigned to the bitmap. This determines the physical size of the bitmap.</param>
        /// <returns>The saved bitmap. You should call Dispose when you no longer need the bitmap.</returns>
        public static Bitmap RenderAsBitmap(this GraphDocument doc, Altaxo.Graph.Gdi.BrushX backbrush1, Altaxo.Graph.Gdi.BrushX backbrush2, PixelFormat pixelformat, double sourceDpiResolution, double destinationDpiResolution)
        {
            var imageExporter = Current.ProjectService.GetProjectItemImageExporter(doc);

            if (null == imageExporter)
            {
                return(null);
            }

            Bitmap bitmap = null;

            using (var memStream = new System.IO.MemoryStream())
            {
                var exportOptions = new Altaxo.Graph.Gdi.GraphExportOptions();
                exportOptions.TrySetImageAndPixelFormat(ImageFormat.Png, PixelFormat.Format32bppArgb);
                exportOptions.SourceDpiResolution      = sourceDpiResolution;
                exportOptions.DestinationDpiResolution = destinationDpiResolution;
                exportOptions.BackgroundBrush          = backbrush1;
                imageExporter.ExportAsImageToStream(doc, exportOptions, memStream);

                memStream.Seek(0, System.IO.SeekOrigin.Begin);
                bitmap = (Bitmap)Bitmap.FromStream(memStream);
            }

            int bmpWidth  = bitmap.Width;
            int bmpHeight = bitmap.Height;

            /*
             *                double outputScaling = sourceDpiResolution / destinationDpiResolution;
             *                bitmap.SetResolution((float)(bmpWidth / (outputScaling * doc.Size.X / 72)), (float)(bmpHeight / (outputScaling * doc.Size.Y / 72)));
             *
             *                using (Graphics grfx = Graphics.FromImage(bitmap))
             *                {
             *                        // Set everything to high quality
             *                        grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
             *                        grfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
             *
             *                        // 2014-10-10 Setting InterpolationMode to HighQualityBicubic and PixelOffsetMode to HighQuality
             *                        // causes problems when rendering small bitmaps (at a large magnification, for instance the density image legend):
             *                        // the resulting image seems a litte soft, the colors somehow distorted, so I decided not to use them here any more
             *
             *                        //		grfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
             *                        //		grfx.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
             *
             *                        grfx.PageUnit = GraphicsUnit.Point;
             *                        grfx.ScaleTransform((float)outputScaling, (float)outputScaling);
             *                        grfx.SetClip(new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
             *
             *                        if (null != backbrush1)
             *                        {
             *                                backbrush1.SetEnvironment(new RectangleD2D(0, 0, doc.Size.X, doc.Size.Y), sourceDpiResolution);
             *                                grfx.FillRectangle(backbrush1, new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
             *                        }
             *
             *                        if (null != backbrush2)
             *                        {
             *                                backbrush2.SetEnvironment(new RectangleD2D(0, 0, doc.Size.X, doc.Size.Y), sourceDpiResolution);
             *                                grfx.FillRectangle(backbrush2, new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
             *                        }
             *                }
             */

            bitmap.SetResolution((float)destinationDpiResolution, (float)destinationDpiResolution);

            return(bitmap);
        }
예제 #31
0
		public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, GraphExportOptions options, string filename)
		{
			Metafile mf;
			using (System.IO.Stream stream = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
			{
				mf = RenderAsEnhancedMetafileVectorFormat(doc, options, stream);
				stream.Close();
			}
			return mf;
		}
예제 #32
0
        private static string InternalAddClipboardDropDownList(Altaxo.Gui.IClipboardSetDataObject dao, System.Drawing.Bitmap bmp, GraphExportOptions options)
        {
            string filepath = System.IO.Path.GetTempPath();
            string filename = filepath + "AltaxoGraphCopyPage" + options.GetDefaultFileNameExtension();

            ;
            if (System.IO.File.Exists(filename))
            {
                System.IO.File.Delete(filename);
            }

            bmp.Save(filename, options.ImageFormat);

            var coll = new System.Collections.Specialized.StringCollection
            {
                filename
            };

            dao.SetFileDropList(coll);

            return(filename);
        }
예제 #33
0
		private static string InternalAddClipboardDropDownList(Altaxo.Gui.IClipboardSetDataObject dao, System.Drawing.Bitmap bmp, GraphExportOptions options)
		{
			string filepath = System.IO.Path.GetTempPath();
			string filename = filepath + "AltaxoGraphCopyPage" + options.GetDefaultFileNameExtension(); ;
			if (System.IO.File.Exists(filename))
				System.IO.File.Delete(filename);

			bmp.Save(filename, options.ImageFormat);

			System.Collections.Specialized.StringCollection coll = new System.Collections.Specialized.StringCollection();
			coll.Add(filename);
			dao.SetFileDropList(coll);

			return filename;
		}