Function GetBitmap(ByVal sOutputFile As String, ByVal ppbmih As BitmapInfoHeader)
Dim bFound As Boolean
Dim hr As Integer = 0 ' should be of HRESULT type ??
Dim iLoop As Integer
Dim lStreams As Long
MediaDetector.get_OutputStreams(lStreams)
For iLoop = 0 To lStreams
Dim major_type As Guid
hr = MediaDetector.put_CurrentStream(iLoop)
hr = MediaDetector.get_StreamType(major_type)
MediaDetector.put_Filename(sOutputFile)
If major_type = MediaType.Video Then
bFound = True
Exit For
End If
Next
If Not bFound Then Return VFW_E_INVALIDMEDIATYPE ' VFW_E_INVALIDMEDIATYPE does not exist
Dim lWidth As Long = 0, lHeight As Long = 0
Dim tpMediaType As New AMMediaType
hr = MediaDetector.get_StreamMediaType(tpMediaType)
If Succeeded(hr) Then
If tpMediaType.formatType = FormatType.VideoInfo And tpMediaType.formatSize >= Len(VideoInfoHeader) Then 'can't Len(VideoInfoHeader)
Dim pVih As VideoInfoHeader = tpMediaType.formatPtr 'this is no good
lWidth = pVih.BmiHeader.Width
lHeight = pVih.BmiHeader.Height
If (lHeight < 0) Then lHeight *= -1
Else
hr = VFW_E_INVALIDMEDIATYPE ' hr = VFW_E_INVALIDMEDIATYPE does not exist
End If
FreeMediaType(tpMediaType) 'FreeMediaType(mt); there's no freemediatype
End If
If failed(hr) Then Return hr ' failed doesn't exist
Dim lSize As Long
hr = MediaDetector.GetBitmapBits(0, System.DBNull, lWidth, lHeight) you can't say that in vb
If succeeded(hr) Then ' another function out of nowhere
Dim pBuffer(lSize) As Char
If Not pBuffer Then Return E_OUTOFMEMORY ' "not pBuffer" <> (!pBuffer)
Try
hr = MediaDetector.GetBitmapBits(0, null, pBuffer, lWidth, lHeight)
If succeeded(hr) Then
If False Then ' WTF !!! if (*ppbmih) delete[] (*ppbmih);
ppbmih = CType(pBuffer, BitmapInfoHeader) ' non ca , ca marche juste pas
End If
Catch ex As Exception
pBuffer = Nothing
Return E_OUTOFMEMORY ' un autre constante qui existe pas
End Try
End If
End Function