MetafileHeader
Contains attributes of an associated Metafile. Not inheritable.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Windows.Win32.Graphics.GdiPlus;
namespace System.Drawing.Imaging
{
[StructLayout(LayoutKind.Sequential)]
[NullableContext(1)]
[Nullable(0)]
public sealed class MetafileHeader
{
internal global::Windows.Win32.Graphics.GdiPlus.MetafileHeader _header;
public MetafileType Type => (MetafileType)_header.Type;
public int MetafileSize => (int)_header.Size;
public int Version => (int)_header.Version;
public float DpiX => _header.DpiX;
public float DpiY => _header.DpiY;
public Rectangle Bounds => new Rectangle(_header.X, _header.Y, _header.Width, _header.Height);
public MetaHeader WmfHeader {
get {
if (IsWmf())
return new MetaHeader(_header.Anonymous.WmfHeader);
throw Status.InvalidParameter.GetException();
}
}
public int EmfPlusHeaderSize => _header.EmfPlusHeaderSize;
public int LogicalDpiX => _header.LogicalDpiX;
public int LogicalDpiY => _header.LogicalDpiY;
internal MetafileHeader()
{
}
public bool IsWmf()
{
global::Windows.Win32.Graphics.GdiPlus.MetafileType type = _header.Type;
if ((uint)(type - 1) > 1)
return false;
return true;
}
public bool IsWmfPlaceable()
{
return _header.Type == global::Windows.Win32.Graphics.GdiPlus.MetafileType.MetafileTypeWmfPlaceable;
}
public bool IsEmf()
{
return _header.Type == global::Windows.Win32.Graphics.GdiPlus.MetafileType.MetafileTypeEmf;
}
public bool IsEmfOrEmfPlus()
{
global::Windows.Win32.Graphics.GdiPlus.MetafileType type = _header.Type;
if ((uint)(type - 3) > 2)
return false;
return true;
}
public bool IsEmfPlus()
{
global::Windows.Win32.Graphics.GdiPlus.MetafileType type = _header.Type;
if ((uint)(type - 4) > 1)
return false;
return true;
}
public bool IsEmfPlusDual()
{
return _header.Type == global::Windows.Win32.Graphics.GdiPlus.MetafileType.MetafileTypeEmfPlusDual;
}
public bool IsEmfPlusOnly()
{
return _header.Type == global::Windows.Win32.Graphics.GdiPlus.MetafileType.MetafileTypeEmfPlusOnly;
}
public bool IsDisplay()
{
if (IsEmfPlus())
return ((EmfPlusFlags)_header.EmfPlusFlags).HasFlag(EmfPlusFlags.Display);
return false;
}
}
}