Hallo,
habe von einem sehr entgegenkommenden VB6-Programmierer einen Code erhalten um eine DLL anzusprechen. Dabei werden über API GDI32 Funktionen aufgerufen. Nun habe ich leider das Problem, dass ich nicht weiß, wie ich das ganze nach VB.NEt konvertieren soll. Bei folgender (bereits migrierter) Sub komme ich nicht weiter:
Public Sub ShowMpegFilePic(ByRef Picture1 As _
System.Windows.Forms.PictureBox)
Dim myFrame As Integer
Dim myVideoFileInfo As VideoFileInfo
Dim tmpDC As Integer
Dim hBitmap As Integer
Dim RC1 As Integer
Dim RC2 As Integer
Call GetMPEG2FrameInfo(frameinfo) 'Read frame properties
BMPInfoHeader.biSize = 40 'Setup bitmap header
BMPInfoHeader.biWidth = frameinfo.hres 'width of frame/picture
BMPInfoHeader.biHeight = frameinfo.VRes ' height of frame/picture
BMPInfoHeader.biPlanes = 1 'always 1
BMPInfoHeader.biBitCount = 24 '24 Bit color
BMPInfoHeader.biCompression = 0 'No compression
BMPInfoHeader.biSizeImage = frameinfo.VRes * frameinfo.hres * 3 'Bitmap
' size in Bytes
myFrame = GetMPEG2Frame 'Get a pointer to the decoded bitmap form
' mpeg2lib
'Create a compatible bitmap for the picturebox
'UPGRADE_ISSUE: PictureBox Eigenschaft Picture1.hdc wurde nicht
' aktualisiert. Klicken Sie hier für weitere Informationen:
' 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup206" & _
""'
hBitmap = CreateCompatibleBitmap(Picture1.hdc, frameinfo.hres, _
frameinfo.VRes)
'Create a compatible device context for the picturebox
'UPGRADE_ISSUE: PictureBox Eigenschaft Picture1.hdc wurde nicht
' aktualisiert. Klicken Sie hier für weitere Informationen:
' 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup206" & _
""'
tmpDC = CreateCompatibleDC(Picture1.hdc)
If tmpDC <> 0 Then
'if Device Context is valid - Create DIB: hBitmap from pointer:
' myframe and bitmap header: BMPInfoHeader
'UPGRADE_ISSUE: PictureBox Eigenschaft Picture1.hdc wurde nicht
' aktualisiert. Klicken Sie hier für weitere Informationen:
' 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbu" & _
"2064"'
RC1 = SetDIBits(Picture1.hdc, hBitmap, 0, frameinfo.VRes, myFrame, _
BMPInfoHeader, 0)
'select the bitmap into the DC
hBitmap = SelectObject(tmpDC, hBitmap)
'copy the bitmap to the picturebox
'UPGRADE_ISSUE: PictureBox Eigenschaft Picture1.hdc wurde nicht
' aktualisiert. Klicken Sie hier für weitere Informationen:
' 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbu" & _
"2064"'
RC2 = BitBlt(Picture1.hdc, 0, 0, frameinfo.hres, frameinfo.VRes, _
tmpDC, 0, 0, SRCCOPY)
' to resize the picture to new_width and new_height use:
' RC2 = StretchBlt(Picture1.hdc, 0, 0, new_width, new_height,
' tmpDC, 0, 0, frameinfo.hres, frameinfo.VRes, SRCCOPY)
DeleteObject(SelectObject(tmpDC, hBitmap))
'Release the temp Device Context
Call DeleteDC(tmpDC)
End If
'Repaint picturebox
ShowForm1.DefInstance.Picture1.Refresh()
End Sub Das Problem besteht darin, dass die VB.NET PictureBox die Eigenschaft .hdc nicht mehr unterstützt. ein .Handle bringt leider auch keinen Erfolg. Auch probiert habe ich bereits aus einem neuen Image-Object ein Graphics-Objekt zu machen und über GetHdc dieses Objekts die Funktionen aufzurufen. Leider kommt dann die Meldung, dass auf das Objekt bereits zugegriffen wird.
Beim Versuch aus dem Image-Object der PictureBox ein Graphics-Object zu machen tritt natürlich auch ein Fehler auf, da dieses zu Beginn ja noch Nothing ist.
Für Hilfe wäre ich sehr dankbar, weil ich wirklich anstehe
Cu leth |