Grazie della risposta.
Ti invio il codice:
Public Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Timer2.Interval = 1
Timer2.Enabled = True
Timer2.Start()
If ArtemisImageReady(Cam_Handle) = True Then
Dim ptr1 As IntPtr = ArtemisImageBuffer(Cam_Handle)
Call Tele1(ptr1)
End If
End Sub
Public Function Tele1(ByVal PtrVideo As IntPtr)
Dim bmp As Bitmap = New Bitmap(1391, 1039)
bmp = New Bitmap(1391, 1039, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim rect As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height)
Dim pxf As PixelFormat = PixelFormat.Format32bppArgb 'Buono
Dim bmpData As BitmapData = bmp.LockBits(rect, ImageLockMode.ReadOnly, pxf)
Dim numBytes As Integer = Math.Abs(bmpData.Width) * bmp.Height
Dim rgbValues(numBytes * 4) As Byte
Dim Buffer(numBytes) As Integer
Dim ptr As IntPtr = bmpData.Scan0
Dim i As Integer
Marshal.Copy(PtrVideo, Buffer, 0, numBytes)
For i = 0 To numBytes
Dim bytes As Byte() = BitConverter.GetBytes(Buffer(i))
Dim Alpha As Byte = bytes(3)
Dim Red As Byte = bytes(2)
Dim Green As Byte = bytes(1)
Dim Blue As Byte = bytes(0)
rgbValues(i * 4 + 0) = Blue
rgbValues(i * 4 + 1) = Green
rgbValues(i * 4 + 2) = Red
rgbValues(i * 4 + 3) = Alpha
Next
Marshal.Copy(rgbValues, 0, ptr, numBytes * 4)
bmp.UnlockBits(bmpData)
PictureBox1.Image = bmp
ArtemisStartOverlappedExposure(Cam_Handle)
End Function
Non so se la procedura d'invio è quella giusta.
Grazie
|