Date: 02-16-2022
Return to Index
created by gbSnippets
Type EncoderParameter Dword
pGuid As Guid ' // GUID of the parameter
NumberOfValues As Dword ' // Number of the parameter values
dwType As Dword ' // Value type, like ValueTypeLONG etc.
Value As Dword ' // A pointer to the parameter values
End Type
Type EncoderParameters Dword
Count As Dword ' // Number of parameters in this structure
Parameter(0) As EncoderParameter ' // Parameter values - variable-length array
End Type
Type GdiplusStartupInput Dword
GdiplusVersion As Dword
DebugEventCallback As Dword
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
Type GdiplusStartupOutput Dword
NotificationHook As Dword
NotificationUnhook As Dword
End Type
Type ImageCodecInfo Dword
Clsid As Guid ' CLSID
FormatID As Guid ' GUID
CodecName As Word Ptr ' const WCHAR*
DllName As Word Ptr ' const WCHAR*
FormatDescription As Word Ptr ' const WCHAR*
FilenameExtension As Word Ptr ' const WCHAR*
MimeType As Word Ptr ' const WCHAR*
Flags As Dword ' DWORD
Version As Dword ' DWORD
SigCount As Dword ' DWORD
SigSize As Dword ' DWORD
SigPattern As Byte Ptr ' const BYTE*
SigMask As Byte Ptr ' const BYTE*
End Type
%MatrixOrderPrepend = 0
Declare Function GdiplusStartup Lib "gdiplus.dll" Alias "GdiplusStartup" (ByRef token As Dword, ByRef Input As GdiplusStartupInput, ByRef Output As GdiplusStartupOutput) As Long
Declare Sub GdiplusShutdown Lib "gdiplus.dll" Alias "GdiplusShutdown" (ByVal token As Dword)
Declare Function GdipCreateFromHDC Lib "gdiplus.dll" Alias "GdipCreateFromHDC" (ByVal hdc As Dword, ByRef graphics As Dword) As Long
Declare Function GdipLoadImageFromFile Lib "gdiplus.dll" Alias "GdipLoadImageFromFile" (ByVal filename As Dword, ByRef Image As Dword) As Long
Declare Function GdipTranslateWorldTransform Lib "gdiplus.dll" Alias "GdipTranslateWorldTransform" (ByVal graphics As Dword, ByVal dx As Single, ByVal dy As Single, ByVal order As Long) As Long
Declare Function GdipRotateWorldTransform Lib "gdiplus.dll" Alias "GdipRotateWorldTransform" (ByVal graphics As Dword, ByVal angle As Single, ByVal order As Long) As Long
Declare Function GdipDrawImage Lib "gdiplus.dll" Alias "GdipDrawImage"(ByVal graphics As Dword, ByVal Image As Dword, ByVal x As Single, ByVal y As Single) As Long ' GpStatus
Declare Function GdipDisposeImage Lib "gdiplus.dll" Alias "GdipDisposeImage" (ByVal Image As Dword) As Long
Declare Function GdipDeleteGraphics Lib "gdiplus.dll" Alias "GdipDeleteGraphics" (ByVal graphics As Dword) As Long
Declare Function GdipGetImageWidth Lib "GDIPLUS.DLL" Alias "GdipGetImageWidth" (ByVal Image As Dword, ByRef Width As Dword) As Long
Declare Function GdipGetImageHeight Lib "GDIPLUS.DLL" Alias "GdipGetImageHeight" (ByVal Image As Dword, ByRef height As Dword) As Long
%UnitPixel = 2
Declare Function GdipCreatePen1 Lib "gdiplus.dll" Alias "GdipCreatePen1" (ByVal Color As Dword, ByVal Width As Single, ByVal unit As Long, ByRef pen As Dword) As Long
Declare Function GdipDeletePen Lib "gdiplus.dll" Alias "GdipDeletePen" (ByVal pen As Dword) As Long
Declare Function GdipDrawLineI Lib "GDIPLUS.DLL" Alias "GdipDrawLineI" (ByVal graphics As Dword, ByVal pen As Dword, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Declare Function GdipGetImageEncodersSize Lib "GDIPLUS.DLL" Alias "GdipGetImageEncodersSize" (ByRef numEncoders As Dword, ByRef Size As Dword) As Long
Declare Function GdipGetImageEncoders Lib "GDIPLUS.DLL" Alias "GdipGetImageEncoders" (ByVal numEncoders As Dword, ByVal Size As Dword, ByRef encoders As Any) As Long
Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPLUS.DLL" Alias "GdipCreateBitmapFromHBITMAP" (ByVal hbm As Dword, ByVal hpal As Dword, ByRef Bitmap As Dword) As Long
Declare Function GdipSaveImageToFile Lib "GDIPLUS.DLL" Alias "GdipSaveImageToFile" (ByVal Image As Dword, ByVal filename As Dword, ByRef clsidEncoder As Guid, ByRef encoderParams As EncoderParameters) As Long
Declare Function GdipDrawImageRectI Lib "gdiplus.dll" Alias "GdipDrawImageRectI" (ByVal hGraphics???, ByVal nImage???, ByVal x&,ByVal y&, ByVal nWidth&, ByVal nHeight&) As Long
Function GdiPlusGetEncoderClsid (ByVal strMimeType As String) As String
Local hr As Long
Local pImageCodecInfo As ImageCodecInfo Ptr
Local numEncoders As Dword
Local nSize As Dword
Local i As Long
Local wstrlen As Long
Local sMimeType As String
hr = GdipGetImageEncodersSize(numEncoders, nSize)
ReDim buffer(nSize - 1) As Byte
pImageCodecInfo = VarPtr(buffer(0))
hr = GdipGetImageEncoders(numEncoders, nSize, ByVal pImageCodecInfo)
If hr = 0 Then
For i = 1 To numEncoders
wstrlen = lstrlenW(ByVal @pImageCodecInfo.MimeType)
If wstrlen Then sMimeType = ACode$(Peek$(@pImageCodecInfo.MimeType, wstrlen * 2))
If InStr(UCase$(sMimeType), UCase$(strMimeType)) Then
Function = GuidTxt$(@pImageCodecInfo.Clsid)
Exit For
End If
Incr pImageCodecInfo '// Increments pointer
Next
End If
End Function
'gbs_00477
'Date: 03-06-2012
http://www.garybeene.com/sw/gbsnippets.htm