掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
画像ファイルのフォーマットを識別するには? (ID:139267)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> これを VBA で使うための宣言や方法が分からないのです。 こちらは、こんな感じかな。 Option Explicit Private Declare Function GdiplusStartup Lib "GDIPlus" _ (ByRef hToken As Long, _ ByRef inputBuf As Long, _ ByVal outputBuf As Long) As Long Private Declare Sub GdiplusShutdown Lib "GDIPlus" _ (ByVal token As Long) Private Declare Function GdipLoadImageFromFile Lib "GDIPlus" _ (ByVal FileName As Long, _ ByRef hImage As Long) As Long Private Declare Function GdipDisposeImage Lib "GDIPlus" _ (ByVal hImage As Long) As Long Private Declare Function GdipGetImageRawFormat Lib "GDIPlus" _ (ByVal hImage As Long, _ ByRef fmt As Currency) As Long Public Function GetFormat(ByVal FileName As String) As String Dim ret As Long Dim hToken As Long Dim startInfo(3) As Long startInfo(0) = 1 ret = GdiplusStartup(hToken, startInfo(0), 0&) If ret <> 0 Then GetFormat = "Error:" & CStr(ret) Exit Function End If Dim hImage As Long ret = GdipLoadImageFromFile(StrPtr(FileName), hImage) If ret <> 0 Then GetFormat = "Error:" & CStr(ret) GdiplusShutdown hToken Exit Function End If Dim fmt(1) As Currency ret = GdipGetImageRawFormat(hImage, fmt(0)) If ret = 0 Then GetFormat = "Unknown" If fmt(1) = 338308179558612.8797@ Then Select Case fmt(0) Case 128437819022162.2443@ GetFormat = "BMP" Case 128437819022162.2444@ GetFormat = "EMF" Case 128437819022162.2445@ GetFormat = "WMF" Case 128437819022162.2446@ GetFormat = "JPEG" Case 128437819022162.2447@ GetFormat = "PNG" Case 128437819022162.2448@ GetFormat = "GIF" Case 128437819022162.2449@ GetFormat = "TIFF" Case 128437819022162.2453@ GetFormat = "ICO" End Select End If Else GetFormat = "Error:" & CStr(ret) End If GdipDisposeImage hImage GdiplusShutdown hToken End Function
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.