' Classes/System/Drawing/Imaging/MetafileHeader.ab

Type Align(8) ENHMETAHEADER3
	iType As DWord
	nSize As DWord

	rclBounds As RECTL
	rclFrame As RECTL
	dSignature As DWord
	nVersion As DWord
	nBytes As DWord
	nRecords As DWord
	nHandles As Word

	sReserved As Word
	nDescription As DWord

	offDescription As DWord

	nPalEntries As DWord
	szlDevice As SIZEL
	szlMillimeters As SIZEL
End Type

' Placeable WMFs

Type Align(2) PWMFRect16
	Left As Word
	Top As Word
	Right As Word
	Bottom As Word
End Type

Type Align(2) WmfPlaceableFileHeader
	Key As DWord
	Hmf As Word
	BoundingBox As PWMFRect16
	Inch As Word
	Reserved As DWord
	Checksum As Word
End Type

Const GDIP_EMFPLUSFLAGS_DISPLAY      = &h00000001

Class MetafileHeader
Private
	mfType As MetafileType
	Size As DWord
	version As DWord
	emfPlusFlags As DWord
	dpiX As Single
	dpiY As Single
	X As Long
	Y As Long
	Width As Long
	Height As Long
	'Union
	'	WmfHeader As METAHEADER
		EmfHeader As ENHMETAHEADER3
	'End Union
	emfPlusHeaderSize As Long
	logicalDpiX As Long
	logicalDpiY As Long
Public
	Function MetafileType() As MetafileType
		Return mfType
	End Function

	Function EmfPlusHeaderSize() As DWord
		Return emfPlusHeaderSize
	End Function

	Function Version() As DWord
		Return version
	End Function

	Function EmfPlusFlags() As DWord
		Return emfPlusFlags
	End Function

	Function DpiX() As Single
		Return dpiX
	End Function

	Function DpiY() As Single
		Return dpiY
	End Function

	Function Bounds() As Rectangle
		Dim r(X, Y, Width, Height)
		Return r
	End Function

	Function LogicalDpiX() As Single
		Return logicalDpiX
	End Function

	Function LogicalDpiY() As Single
		Return logicalDpiY
	End Function

	Function IsWmf() As BOOL
		IsWmf = (mfType = MetafileTypeWmf Or mfType = MetafileTypeWmfPlaceable)
	End Function

	Function IsWmfPlaceable() As BOOL
		IsWmfPlaceable = (mfType = MetafileTypeWmfPlaceable)
	End Function

	Function IsEmf() As BOOL
		IsEmf = (mfType = MetafileTypeEmf)
	End Function

	Function IsEmfOrEmfPlus() As BOOL
		IsEmfOrEmfPlus = (mfType >= MetafileTypeEmf)
	End Function

	Function IsEmfPlus() As BOOL
		IsEmfPlus = (mfType >= MetafileTypeEmfPlusOnly)
	End Function

	Function IsEmfPlusDual() As BOOL
		IsEmfPlusDual = (mfType = MetafileTypeEmfPlusDual)
	End Function

	Function IsEmfPlusOnly() As BOOL /*const*/
		IsEmfPlusOnly = (mfType = MetafileTypeEmfPlusOnly)
	End Function

	Function IsDisplay() As BOOL
		If IsEmfPlus() <> FALSE And ((EmfPlusFlags And GDIP_EMFPLUSFLAGS_DISPLAY) <> 0) Then
			IsDisplay = _System_TRUE
		Else
			IsDisplay = _System_FALSE
	End Function

	Function WmfHeader() As *METAHEADER 'const METAHEADER* const
		If IsWmf() Then
			Return VarPtr(EmfHeader) 'VarPtr(WmfHeader)
		Else
			Return 0
		End If
	End Function

	Function GetEmfHeader() As * /*const*/ ENHMETAHEADER3 /*const*/
		If IsEmfOrEmfPlus() Then
			Return VarPtr(EmfHeader) 'VarPtr(WmfHeader)
		Else
			Return 0
		End If
	End Function
End Class
