private IntPtr RenderWindowsMetafilePict(TYMED tymed) { ComDebug.ReportInfo("GraphDocumentDataObject.RenderWindowsMetafilePict"); if (!(tymed == TYMED.TYMED_MFPICT)) { throw new ArgumentException(nameof(tymed) + " is not TYMED_MFPICT"); } if (null != _graphDocumentBitmapImage) { using (var rgbBitmap = GraphDocumentExportActions.ConvertBitmapToPixelFormat(_graphDocumentBitmapImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb, _graphExportOptions.BackgroundColorForFormatsWithoutAlphaChannel)) { var scaledDocSize = _graphDocumentSize * _graphExportOptions.OutputScalingFactor; using (var enhancedMetafile = GraphDocumentExportActions.RenderAsEnhancedMetafileBitmapFormat(rgbBitmap, scaledDocSize)) { var hEmf = enhancedMetafile.GetHenhmetafile(); return(DataObjectHelper.ConvertEnhancedMetafileToWindowsMetafilePict(hEmf, scaledDocSize.X, scaledDocSize.Y)); } } } else { throw new InvalidProgramException("Please report this exception to the author of the program and describe the steps to reproduce the exception"); } }
/// <summary> /// Renders the provided graph document to an windows metafile picture (TYMED_MFPICT). Please not that this format does not support transparancy, thus the back color provided in the rendering options is used as ground brush first. /// </summary> /// <param name="tymed">The tymed to check.</param> /// <param name="document">The graph document.</param> /// <returns>Pointer to windows metafile picture (TYMED_MFPICT).</returns> public static IntPtr RenderWindowsMetafilePict_TYMED_MFPICT(TYMED tymed, GraphDocumentBase document) { if (!(tymed == TYMED.TYMED_MFPICT)) { throw new ArgumentException(nameof(tymed) + " is not TYMED_MFPICT"); } var renderingOptions = GetRenderingOptions(document); using (var rgbBitmap = Altaxo.Graph.GraphDocumentBaseExportActions.RenderAsBitmap(document, renderingOptions, System.Drawing.Imaging.PixelFormat.Format24bppRgb)) { var scaledDocSize = document.Size * renderingOptions.OutputScalingFactor; using (var enhancedMetafile = GraphDocumentExportActions.RenderAsEnhancedMetafileBitmapFormat(rgbBitmap, scaledDocSize)) { var hEmf = enhancedMetafile.GetHenhmetafile(); return(DataObjectHelper.ConvertEnhancedMetafileToWindowsMetafilePict(hEmf, scaledDocSize.X, scaledDocSize.Y)); } } }