本文整理汇总了C#中System.Drawing.Imaging.Metafile.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Metafile.Clone方法的具体用法?C# Metafile.Clone怎么用?C# Metafile.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Imaging.Metafile
的用法示例。
在下文中一共展示了Metafile.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImageFromParams
private static Image GetImageFromParams(object pict, IntPtr handle, int pictype, IntPtr paletteHandle, int width,
int height)
{
switch (pictype)
{
case -1:
return null;
case 0:
return null;
case 1:
return Image.FromHbitmap(handle, paletteHandle);
case 2:
{
var wmfHeader = new WmfPlaceableFileHeader();
wmfHeader.BboxRight = (short) width;
wmfHeader.BboxBottom = (short) height;
var metafile = new Metafile(handle, wmfHeader, false);
return (Image) RuntimeHelpers.GetObjectValue(metafile.Clone());
}
case 4:
{
var metafile2 = new Metafile(handle, false);
return (Image) RuntimeHelpers.GetObjectValue(metafile2.Clone());
}
}
throw new Exception("AXUnknownImage");
}
示例2: Metafile_String
public void Metafile_String ()
{
string filename = getInFile (WmfPlaceable);
Metafile mf = new Metafile (filename);
Metafile clone = (Metafile) mf.Clone ();
}
示例3: TryPasteEnhancedMetafile
//*************************************************************************
// Method: TryPasteEnhancedMetafile()
//
/// <summary>
/// Attempts to paste an enhanced metafile from the clipboard into the
/// PictureBox.
/// </summary>
///
/// <returns>
/// true if an enhanced metafile was pasted into the PictureBox.
/// </returns>
///
/// <remarks>
/// If the clipboard contains an enhanced metafile, this method pastes it
/// into the PictureBox and returns true. Otherwise, false is returned.
/// </remarks>
//*************************************************************************
public Boolean TryPasteEnhancedMetafile()
{
// This interop code was adapted from the following post:
//
// http://www.eggheadcafe.com/community/aspnet/12/10018506/
// how-to-paste--metafile-fr.aspx
//
// NOTE: Do not try this non-interop technique:
//
// Object oData = Clipboard.GetData(DataFormats.EnhancedMetafile);
//
// if (oData != null)
// {
// System.Drawing.Imaging.Metafile oMetafile =
// (System.Drawing.Imaging.Metafile)oData;
// }
//
// When pasting from a chart image copied from Excel, the GetData()
// call crashes Excel. Although the Clipboard class reports that the
// DataFormats.EnhancedMetafile format is available (along with
// "Preferred DropEffect", "InShellDragLoop", and "MetaFilePict"), it
// does not seem to be the format that the .NET Framework is expecting.
// Using the interop technique below works properly, however.
Boolean bReturn = false;
if ( OpenClipboard(this.Handle) )
{
if ( IsClipboardFormatAvailable(CF_ENHMETAFILE) )
{
IntPtr oPtr = GetClipboardData(CF_ENHMETAFILE);
if ( !oPtr.Equals( new IntPtr(0) ) )
{
Metafile oMetafile = new Metafile(oPtr, true);
this.Image = (Metafile)oMetafile.Clone();
bReturn = true;
}
}
CloseClipboard();
}
return (bReturn);
}