Ejemplo n.º 1
0
        /// <summary>
        /// Copies the current graph as an bitmap image to the clipboard in native bmp format.
        /// </summary>
        /// <param name="doc">Graph to copy to the clipboard.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        public static void CopyToClipboardAsBitmap(this GraphDocument doc, int dpiResolution, BrushX backbrush, PixelFormat pixelformat)
        {
            var dao = Current.Gui.GetNewClipboardDataObject();

            System.Drawing.Bitmap bitmap = GraphDocumentExportActions.RenderAsBitmap(doc, backbrush, pixelformat, dpiResolution, dpiResolution);
            dao.SetImage(bitmap);
            Current.Gui.SetClipboardDataObject(dao);
        }
Ejemplo n.º 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));
     }
 }