vb6 -> .net

Hallo,

gestern hatten wir hier eine Frage zum speichern eines Bildes.
Inzwischen weiß ich, daß das Programm .NET ist und habe die Frage ins richtige Brett verschoben.

Mit VB6 war das Programm sehr schnell nachgebaut und auch nicht mehr sehr umfangreich, dafür sehr viel schneller. Kann eventuell mal Jemand, der Beides kann über den Code sehen und das Programm eventuell nach .NET umschreiben? (Alex?)

Gruß Rainer

Antworten bitte im Brett .NET
/t/bild-aus-picturebox-speichern/4621106

PS. Der VB6 Code. Der läuft, muss nicht verändert werden.

Option Explicit

Private Type BITMAP
 bmType As Long
 bmWidth As Long
 bmHeight As Long
 bmWidthBytes As Long
 bmPlanes As Integer
 bmBitsPixel As Integer
 bmBits As Long
End Type
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Dim PicBits() As Byte, PicInfo As BITMAP
Dim Cnt As Long, BytesPerLine As Long

Private Sub Command2\_Click()
 Dim tm As Long
 tm = Timer
 GetObject Picture1.Image, Len(PicInfo), PicInfo
 BytesPerLine = (PicInfo.bmWidth \* 3 + 3) And &HFFFFFFFC
 ReDim PicBits(1 To BytesPerLine \* PicInfo.bmHeight \* 3) As Byte
 GetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)

 'Auswertung
 For Cnt = 1 To UBound(PicBits) Step 4
 If PicBits(Cnt) \> 100 Then
 PicBits(Cnt) = 255
 PicBits(Cnt + 1) = 255
 PicBits(Cnt + 2) = 255
 End If
 Next Cnt

 SetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
 Picture1.Refresh
 Me.Caption = Round(Timer - tm, 2)
End Sub

Private Sub Command1\_Click()
 CommonDialog1.ShowOpen
 Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub


Private Sub Command3\_Click()
 CommonDialog1.ShowSave
 SavePicture Picture1.Image, CommonDialog1.FileName
End Sub

Private Sub Form\_Load()
 Picture1.AutoSize = True
 Picture1.AutoRedraw = True
 Command1.Caption = "laden"
 Command2.Caption = "bearbeiten"
 Command3.Caption = "sichern"
End Sub