'これだと NG っぽい Option Explicit Private m_lToken As Long Private Type GdiplusStartupInput GdiplusVersion As Long DebugEventCallback As Long SuppressBackgroundThread As Long SuppressExternalCodecs As Long End Type Private Declare Function GdiplusStartup Lib "gdiplus" ( _ token As Long, inputbuf As GdiplusStartupInput, _ Optional ByVal outputbuf As Long = 0) As Long Private Declare Function GdiplusShutdown Lib "gdiplus" ( _ ByVal token As Long) As Long Private Declare Function GdipCreateFromHDC Lib "gdiplus" ( _ ByVal hdc As Long, graphics As Long) As Long 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 GdipDrawImageRectI Lib "gdiplus" ( _ ByVal graphics As Long, ByVal image As Long, _ ByVal X As Long, ByVal Y As Long, _ ByVal Width As Long, ByVal Height As Long) As Long Private Declare Function GdipDeleteGraphics Lib "gdiplus" ( _ ByVal graphics As Long) As Long Private Declare Function GdipDisposeImage Lib "gdiplus" ( _ ByVal image As Long) As Long Private Declare Function GdipLoadImageFromStream Lib "gdiplus" _ (ByVal stm As IStream, _ ByRef img As OLE_HANDLE) As Long Private Declare Function GdipLoadImageFromStream2 Lib "gdiplus" Alias "GdipLoadImageFromStream" _ (ByVal stm As stdole.IUnknown, _ ByRef img As OLE_HANDLE) As Long Private Const GENERIC_READ As Long = &H80000000 Private Const GENERIC_WRITE As Long = &H40000000 Private Declare Function GdipCreateStreamOnFile Lib "gdiplus" _ (ByVal filename As Long, _ ByVal access As Long, _ ByRef img As stdole.IUnknown) As Long Private Sub Command1_Click() Dim strFileName As String strFileName = Text1.Text Dim img As OLE_HANDLE Dim ret As Long Dim lngWidth As Long Dim lngHeight As Long Dim g As OLE_HANDLE Picture1.Cls ret = GdipCreateFromHDC(Picture1.hdc, g) Dim stm As ADODB.Stream Set stm = New ADODB.Stream stm.Type = adTypeBinary stm.Open stm.LoadFromFile strFileName ret = GdipLoadImageFromStream(stm, img) ret = GdipGetImageWidth(img, lngWidth) ret = GdipGetImageHeight(img, lngHeight) ret = GdipDrawImageRectI(g, img, 0, 0, lngWidth, lngHeight) stm.Close ret = GdipDeleteGraphics(g) ret = GdipDisposeImage(img) Set stm = Nothing Picture1.Refresh End Sub Private Sub Command2_Click() Dim strFileName As String strFileName = Text1.Text Dim img As OLE_HANDLE Dim ret As Long Dim lngWidth As Long Dim lngHeight As Long Dim g As OLE_HANDLE Picture1.Cls ret = GdipCreateFromHDC(Picture1.hdc, g) Dim pStm As stdole.IUnknown ret = GdipCreateStreamOnFile(StrPtr(strFileName), GENERIC_READ Or GENERIC_WRITE, pStm) ret = GdipLoadImageFromStream2(pStm, img) Set pStm = Nothing ret = GdipGetImageWidth(img, lngWidth) ret = GdipGetImageHeight(img, lngHeight) ret = GdipDrawImageRectI(g, img, 0, 0, lngWidth, lngHeight) ret = GdipDeleteGraphics(g) ret = GdipDisposeImage(img) Picture1.Refresh End Sub Private Sub Form_Load() Dim gsi As GdiplusStartupInput gsi.GdiplusVersion = 1 Call GdiplusStartup(m_lToken, gsi) Picture1.AutoRedraw = True End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Call GdiplusShutdown(m_lToken) End Sub