'GDI+開始 Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, pInput As GdiplusStartupInput, _ pOutput As Any) As Long 'GDI+終了 Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal token As Long) 'Image削除 Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As Long 'Imageの寸法取得 Private Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal image As Long, Width As Long) As Long Private Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal image As Long, Height As Long) As Long Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (FileName As Any, bitmap As Long) As Long ' GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) Private Declare Function GdipBitmapGetPixel Lib "gdiplus" (ByVal bitmap As LongPtr, ByVal x As Long, ByVal y As Long, ByRef color As Long) As Long Private Type GdiplusStartupInput GdiplusVersion As Long DebugEventCallback As Long SuppressBackgroundThread As Long SuppressExternalCodecs As Long End Type Private Type PICTDESC cbSizeofStruct As Long picType As Long hbitmap As Long hpal As Long unused_wmf_yExt As Long End Type Dim pDstBmp As Long Dim color As Long Dim pd As PICTDESC Dim lngToken As Long Dim udtInput As GdiplusStartupInput Dim pSrcBmp As Long Dim lngWidth As Long, lngHeight As Long Dim fn As String Dim R As Long Dim G As Long Dim B As Long Dim c1 As Long Dim c2 As Long Dim color1 As Long Sub MacroGDIP() fn = "E:\HOGEHOGE\TEST.png" ' 初期化 udtInput.GdiplusVersion = 1 If GdiplusStartup(lngToken, udtInput, ByVal 0&) <> 0 Then MsgBox "a1" End If ' 画像の読みこみ If GdipCreateBitmapFromFile(ByVal StrPtr(fn), pSrcBmp) <> 0 Then GdiplusShutdown lngToken MsgBox "a2" End If ' 元画像サイズの取得 GdipGetImageWidth pSrcBmp, lngWidth GdipGetImageHeight pSrcBmp, lngHeight Call GdipBitmapGetPixel(pSrcBmp, 199, 199, color) R = Int(color / 256 / 256) G = Int(color / 256) Mod 256 B = color Mod 256 'ここが良くわかりませんでした。 R = R + 256 G = G + 256 B = B + 256 h = R * 256 * 256 + G * 256 + B MsgBox R & ";" & G & ";" & B & ";" & lngWidth & ";" & lngHeight & ";" & h End Sub