Index: Include/api_gdi.sbp
===================================================================
--- Include/api_gdi.sbp	(revision 121)
+++ Include/api_gdi.sbp	(revision 123)
@@ -9,8 +9,8 @@
 Const GDI_ERROR =     &HFFFFFFFF
 
+TypeDef BCHAR = TBYTE
 
 Type _System_DeclareHandle_HPALETTE:unused As DWord:End Type
 TypeDef HPALETTE = *_System_DeclareHandle_HPALETTE
-
 
 ' Point/Rectangle/Size struct
@@ -30,4 +30,10 @@
 	cx As Long
 	cy As Long
+End Type
+
+' Metafile and EnhancedMetafile
+Type EMR
+	iType As DWord
+	nSize As DWord
 End Type
 
@@ -43,5 +49,61 @@
 TypeDef PMETAHEADER = *METAHEADER
 
+Type ENHMETAHEADER
+    iType As DWord
+    nSize As DWord
+    rclBounds As RECT
+    rclFrame As RECT
+    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 SIZE
+    szlMillimeters As SIZE
+    cbPixelFormat As DWord
+    offPixelFormat As DWord
+    bOpenGL As DWord
+'#if WINVER >= 0x0500
+    'szlMicrometers As SIZE
+'#endif
+End Type
+TypeDef PENHMETAHEADER = *ENHMETAHEADER
+
+Type HANDLETABLE
+	objectHandle[ELM(1)] As HGDIOBJ
+End Type
+
+Type METARECORD
+	rdSize As DWord
+	rdFunction As Word
+	rdParm[ELM(1)] As Word
+End Type
+
+Type ENHMETARECORD
+	iType As DWord
+	nSize As DWord
+	dParm[ELM(1)] As DWord
+End Type
+
+Type METAFILEPICT
+	mm As Long
+	xExt As Long
+	yExt As Long
+	hMF As HMETAFILE
+End Type
+
+TypeDef ENHMFENUMPROC = *Function(hdc As HDC, ByRef HTable As HANDLETABLE, ByRef EMFR As ENHMETARECORD, nObj As Long, lpData As LPARAM) As Long
+TypeDef MFENUMPROC = *Function(hdc As HDC, ByRef HTable As HANDLETABLE, ByRef MFR As METARECORD, nObj As Long, lpClientData As LPARAM)
+
+
+' RGB Color
 Const RGB(r, g, b) = ((r) As Long) Or (((g) As Long) <<8) Or (((b) As Long) <<16)
+Const PALETTERGB(r, g, b) = (&h02000000 Or RGB(r,g,b))
+Const PALETTEINDEX(i) = ((&h01000000 Or (i) As Word As DWord) As COLORREF)
+
 Const GetRValue(rgb) = (rgb And &hff)
 Const GetGValue(rgb) = ((rgb >> 8) And &hff)
@@ -54,4 +116,72 @@
 	rgbReserved As Byte
 End Type
+
+Type Align(1) RGBTRIPLE
+	rgbtBlue As Byte
+	rgbtGreen As Byte
+	rgbtRed As Byte
+End Type
+
+' CMYK Color
+Const GetKValue(cmyk) = ((cmyk) As Byte)
+Const GetYValue(cmyk) = (((cmyk) >> 8) As Byte)
+Const GetMValue(cmyk) = (((cmyk) >> 16) As Byte)
+Const GetCValue(cmyk) = (((cmyk) >> 24) As Byte)
+
+Const CMYK(c, m, y, k) = (( _
+	((k) As Byte) Or _
+	((y) As Byte As Word << 8) Or _
+	((m) As Byte As DWord << 16) Or _
+	((c) As Byte As DWord << 24)) As COLORREF)
+
+' ICM Color
+TypeDef FXPT16DOT16 = Long
+TypeDef FXPT2DOT30 = Long
+
+TypeDef LCSCSTYPE = Long
+TypeDef LCSGAMUTMATCH = Long
+
+Type LOGCOLORSPACEA
+	lcsSignature As DWord
+	lcsVersion As DWord
+	lcsSize As DWord
+	lcsCSType As LCSCSTYPE
+	lcsIntent As LCSGAMUTMATCH
+	lcsEndpoints As CIEXYZTRIPLE
+	lcsGammaRed As DWord
+	lcsGammaGreen As DWord
+	lcsGammaBlue As DWord
+	lcsFilename[MAX_PATH] As SByte
+End Type
+Type LOGCOLORSPACEW
+	lcsSignature As DWord
+	lcsVersion As DWord
+	lcsSize As DWord
+	lcsCSType As LCSCSTYPE
+	lcsIntent As LCSGAMUTMATCH
+	lcsEndpoints As CIEXYZTRIPLE
+	lcsGammaRed As DWord
+	lcsGammaGreen As DWord
+	lcsGammaBlue As DWord
+	lcsFilename[ELM(MAX_PATH)] As WCHAR
+End Type
+#ifdef UNICODE
+TypeDef LOGCOLORSPACE = LOGCOLORSPACEW
+#else
+TypeDef LOGCOLORSPACE = LOGCOLORSPACEA
+#endif
+
+Type CIEXYZ
+	ciexyzX As FXPT2DOT30
+	ciexyzY As FXPT2DOT30
+	ciexyzZ As FXPT2DOT30
+End Type
+
+Type CIEXYZTRIPLE
+	ciexyzRed As CIEXYZ
+	ciexyzGreen As CIEXYZ
+	ciexyzBlue As CIEXYZ
+End Type
+
 
 
@@ -101,4 +231,16 @@
 End Type
 
+Type BITMAPCOREHEADER
+	bcSize As DWord
+	bcWidth As Word
+	bcHeight As Word
+	bcPlanes As Word
+	bcBitCount As Word
+End Type
+
+Type BITMAPCOREINFO
+	bmciHeader As BITMAPCOREHEADER
+	bmciColors[ELM(1)] As RGBTRIPLE
+End Type
 
 ' structures for defining DIBs
@@ -109,4 +251,5 @@
 Const BI_JPEG =      4
 Const BI_PNG =       5
+
 Type BITMAPINFOHEADER
 	biSize As DWord
@@ -122,7 +265,8 @@
 	biClrImportant As DWord
 End Type
+
 Type BITMAPINFO
 	bmiHeader As BITMAPINFOHEADER
-	bmpColors[255] As RGBQUAD
+	bmiColors[ELM(1)] As RGBQUAD '以前はbmpColors[255] As RGBQUADだったことに注意
 End Type
 
@@ -137,4 +281,26 @@
 End Type
 
+Type BITMAPV4HEADER
+	bV4Size As DWord
+	bV4Width As Long
+	bV4Height As Long
+	bV4Planes As Word
+	bV4BitCount As Word
+	bV4V4Compression As DWord
+	bV4SizeImage As DWord
+	bV4XPelsPerMeter As Long
+	bV4YPelsPerMeter As Long
+	bV4ClrUsed As DWord
+	bV4ClrImportant As DWord
+	bV4RedMask As DWord
+	bV4GreenMask As DWord
+	bV4BlueMask As DWord
+	bV4AlphaMask As DWord
+	bV4CSType As DWord
+	bV4Endpoints As CIEXYZTRIPLE
+	bV4GammaRed As DWord
+	bV4GammaGreen As DWord
+	bV4GammaBlue As DWord
+End Type
 
 ' Region flags
@@ -327,5 +493,7 @@
 Declare Function CancelDC Lib "gdi32" (hdc As HDC) As BOOL
 Declare Function Chord Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nXRadial1 As Long, nYRadial1 As Long, nXRadial2 As Long, nYRadial2 As Long) As BOOL
+Declare Function CloseEnhMetaFile Lib "gdi32" (hdc As HDC) As HENHMETAFILE
 Declare Function CloseFigure Lib "gdi32" (hdc As HDC) As BOOL
+Declare Function CloseMetaFile Lib "gdi32" (hdc As HDC) As HMETAFILE
 
 Const RGN_AND =  1
@@ -335,5 +503,6 @@
 Const RGN_COPY = 5
 Declare Function CombineRgn Lib "gdi32" (hrgnDest As HRGN, hrgnSrc1 As HRGN, hrgnSrc2 As HRGN, fnCombineMode As Long) As Long
-
+Declare Function CopyEnhMetaFile Lib "gdi32" Alias "CopyEnhMetaFileA" (hemfSrc As HENHMETAFILE, pszFile As PCSTR) As HENHMETAFILE
+Declare Function CopyMetaFile Lib "gdi32" Alias "CopyMetaFileA" (hmfSrc As HMETAFILE, pszFile As PCSTR) As HMETAFILE
 Declare Function CreateBitmap Lib "gdi32" (nWidth As Long, nHeight As Long, cPlanes As Long, cBitsPerPel As Long, lpvBits As VoidPtr) As HBITMAP
 Declare Function CreateBitmapIndirect Lib "gdi32" (ByRef lpbm As BITMAP) As HBITMAP
@@ -376,4 +545,6 @@
 Declare Function CreateEllipticRgn Lib "gdi32" (nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As HRGN
 Declare Function CreateEllipticRgnIndirect Lib "gdi32" (ByRef lpRect As RECT) As HRGN
+Declare Function CreateEnhMetaFile Lib "gdi32" Alias "CreateEnhMetaFileA" (hdcRef As HDC, pFileName As PCTSTR, ByRef Rect As RECT, pDescription As PCTSTR) As HDC 
+Declare Function CreateMetaFile Lib "gdi32" Alias "CreateMetaFileA" (pFileName As PCTSTR) As HDC 
 
 Const FW_DONTCARE =       0
@@ -518,4 +689,6 @@
 Declare Function CreateSolidBrush Lib "gdi32" (crColor As COLORREF) As HBRUSH
 Declare Function DeleteDC Lib "gdi32" (hdc As HDC) As BOOL
+Declare Function DeleteEnhMetaFile Lib "gdi32" (hemf As HENHMETAFILE) As BOOL
+Declare Function DeleteMetaFile Lib "gdi32" (hmf As HMETAFILE) As BOOL
 Declare Function DeleteObject Lib "gdi32" (hObject As HANDLE) As BOOL
 Declare Function DPtoLP Lib "gdi32" (hdc As HDC, ByRef lpPoints As POINTAPI, nCount As Long) As BOOL
@@ -524,4 +697,6 @@
 Declare Function EndPage Lib "gdi32" (hdc As HDC) As Long
 Declare Function EndPath Lib "gdi32" (hdc As HDC) As BOOL
+Declare Function EnumEnhMetaFile Lib "gdi32" (hdc As HDC, hemf As HENHMETAFILE, pEnhMetaFunc As ENHMFENUMPROC, pData As VoidPtr, ByRef Rect As RECT) As BOOL
+Declare Function EnumMetaFile Lib "gdi32" (hdc As HDC, hmf As HMETAFILE, pMetaFunc As MFENUMPROC, lParam As LPARAM) As BOOL
 Declare Function EqualRgn Lib "gdi32" (hSrcRgn1 As HRGN, hSrcRgn2 As HRGN) As BOOL
 Declare Function ExcludeClipRect Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long
@@ -552,5 +727,6 @@
 Declare Function FillRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, hBrush As HBRUSH) As Long
 Declare Function FrameRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, hBrush As HBRUSH, nWidth As Long, nHeight As Long) As Long
-Declare Function GetBitmapBits Lib "gdi32" (hbmp As HBITMAP,  cbBuffer As Long, lpvBits As VoidPtr) As Long
+Declare Function GdiComment Lib "gdi32" (hdc As HDC, cbSize As DWord, lpData As *Byte) As BOOL
+Declare Function GetBitmapBits Lib "gdi32" (hbmp As HBITMAP, cbBuffer As Long, lpvBits As VoidPtr) As Long
 Declare Function GetBkColor Lib "gdi32" (hdc As HDC) As DWord
 Declare Function GetBkMode Lib "gdi32" (hdc As HDC) As Long
@@ -682,4 +858,9 @@
 
 Declare Function GetDIBits Lib "gdi32" (hdc As HDC, hbmp As HBITMAP, uStartScan As DWord, cScanLines As DWord, lpvBits As VoidPtr, ByRef lpbi As BITMAPINFO, uUsage As DWord) As Long
+Declare Function GetEnhMetaFile Lib "gdi32" Alias "GetEnhMetaFileA" (pszMetaFile As PCSTR) As HENHMETAFILE
+Declare Function GetEnhMetaFileBits Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, pbBuffer As *Byte) As DWord
+Declare Function GetEnhMetaFileDescription Lib "gdi32" Alias "GetEnhMetaFileDescriptionA" (hemf As HENHMETAFILE, cbBuffer As DWord, pszDescription As PTSTR) As DWord
+Declare Function GetEnhMetaFileHeader Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, ByRef emh As ENHMETAHEADER) As DWord
+Declare Function GetEnhMetaFilePaletteEntries Lib "gdi32" (hemf As HENHMETAFILE, cEntries As DWord, ByRef pe As PALETTEENTRY) As DWord
 
 Const MM_TEXT =           1
@@ -692,5 +873,5 @@
 Const MM_ANISOTROPIC =    8
 Declare Function GetMapMode Lib "gdi32" (hdc As HDC) As Long
-
+Declare Function GetMetaFileBitsEx Lib "gdi32" (hmf As HMETAFILE, nSize As DWord, pvData As VoidPtr) As DWord
 Declare Function GetMiterLimit Lib "gdi32" (hdc As HDC, peLimit As SinglePtr) As Long
 Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (hgdiobj As HANDLE, cbBuffer As Long, ByRef lpvObject As Any) As Long
@@ -781,4 +962,5 @@
 Declare Function GetWindowExtEx Lib "gdi32" (hdc As HDC, ByRef lpSize As SIZE) As Long
 Declare Function GetWindowOrgEx Lib "gdi32" (hdc As HDC, ByRef lpPoint As POINTAPI) As Long
+Declare Function GetWinMetaFileBits Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, pbBuffer As *Byte, fnMapMode As Long, hdcRef As HDC) As DWord
 Declare Function IntersectClipRect Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long
 Declare Function InvertRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN) As Long
@@ -794,4 +976,8 @@
 Declare Function PathToRegion Lib "gdi32" (hdc As HDC) As HRGN
 Declare Function Pie Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nXRadial1 As Long, nYRadial1 As Long, nXRadial2 As Long, nYRadial2 As Long) As Long
+Declare Function PlayEnhMetaFile Lib "gdi32" (hdc As HDC, hemf As HENHMETAFILE, ByRef Rect As RECT) As Long
+Declare Function PlayEnhMetaFileRecord Lib "gdi32" (hdc As HDC, ByRef Handletable As HANDLETABLE, ByRef EnhMetaRecord As ENHMETARECORD, nHandles As DWord) As BOOL
+Declare Function PlayMetaFile Lib "gdi32" (hdc As HDC, hmf As HMETAFILE) As BOOL
+Declare Function PlayMetaFileRecord Lib "gdi32" (hdc As HDC, ByRef Handletable As HANDLETABLE, ByRef MetaRecord As METARECORD, nHandles As DWord) As BOOL
 Declare Function PlgBlt Lib "gdi32" (hdcDest As HDC, ByRef lpPoint As POINTAPI, hdcSrc As HDC, nXSrc As Long, nYSrc As Long, nWidth As Long, nHeight As Long, hbmMask As HBITMAP, xMask As Long, yMask As Long) As Long
 Declare Function PolyBezier Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI, cPoints As Long) As Long
@@ -824,5 +1010,7 @@
 Declare Function SetBrushOrgEx Lib "gdi32" (hdc As HDC, nXOrg As Long, nYOrg As Long, ByRef lppt As POINTAPI) As Long
 Declare Function SetDIBits Lib "gdi32" (hdc As HDC, hbmp As HBITMAP, uStartScan As DWord, cScanLines As DWord, lpvBits As VoidPtr, ByRef lpbmi As BITMAPINFO, fuColorUse As DWord) As Long
+Declare Function SetEnhMetaFileBits Lib "gdi32" (cbBuffer As DWord, pData As *Byte) As HENHMETAFILE
 Declare Function SetMapMode Lib "gdi32" (hdc As HDC, fnMapMode As Long) As Long
+Declare Function SetMetaFileBitsEx Lib "gdi32" (nSize As DWord, pData As *Byte) As HMETAFILE
 Declare Function SetMiterLimit Lib "gdi32" (hdc As HDC, eNewLimit As Single, peOldLimit As SinglePtr) As Long
 Declare Function SetPixel Lib "gdi32" (hdc As HDC, x As Long, y As Long, crColor As DWord) As DWord
@@ -847,4 +1035,5 @@
 Declare Function SetWindowExtEx Lib "gdi32" (hdc As HDC, nXExtent As Long, nYExtent As Long, ByRef lpSize As SIZE) As Long
 Declare Function SetWindowOrgEx Lib "gdi32" (hdc As HDC, x As Long, y As Long, ByRef lpPoint As POINTAPI) As Long
+Declare Function SetWinMetaFileBits Lib "gdi32" (cbBuffer As DWord, pbBuffer As *Byte, hdcRef As HDC, ByRef mfp As METAFILEPICT) As HENHMETAFILE
 Declare Function StartDoc Lib "gdi32" Alias "StartDocA" (hdc As HDC, ByRef ref_di As DOCINFO) As Long
 Declare Function StartPage Lib "gdi32" (hdc As HDC) As Long
