Click here to Skip to main content
15,905,683 members

Comments by mehdishahgholi (Top 4 by date)

mehdishahgholi 7-Jul-15 1:24am View    
@Kornfeld Eliyahu Peter: Dear Peter
Yes I know I try this before:
Dim Bitmap As New Bitmap(100, 100, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)
Dim a As Integer = System.Drawing.Imaging.PixelFormat.Format16bppGrayScale
Dim BitmapData As BitmapData = Bitmap.LockBits(New Rectangle(0, 0, Bitmap.Width, Bitmap.Height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)
Dim GrayLevelMap(100 * 100 - 1) As Short
Dim R As New Random
For i = 0 To GrayLevelMap.GetUpperBound(0)
GrayLevelMap(i) = R.Next(0, 32768)
Next
Marshal.CleanupUnusedObjectsInCurrentContext()
Marshal.Copy(GrayLevelMap, 0, BitmapData.Scan0, GrayLevelMap.Length)
Bitmap.UnlockBits(BitmapData)
PictureBox2.Image = Bitmap
but picturebox show a white box with a red x on it !!!
mehdishahgholi 6-Jul-15 7:38am View    
sorry I update the question
mehdishahgholi 21-Oct-14 7:45am View    
:) sure, Here is the code:


<DllImport("VADAV.DLL", EntryPoint:="VD_GetHomeDirectory", SetLastError:=True, CharSet:=CharSet.Auto, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)>
Public Shared Sub VD_GetHomeDirectory(ByRef Dir As StringBuilder)
End Sub
Private Sub HomeButton_Click(sender As System.Object, e As System.EventArgs) Handles HomeButton.Click
Dim Dir As New StringBuilder(100)
VD_GetHomeDirectory(Dir)
End Sub

AccessViolationException error happen and this is the message:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I worked with two other function of this DLL with no problem as below:


<DllImport("VADAV.DLL", EntryPoint:="VD_GetImage", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)>
Private Shared Function VD_GetImage(ByRef W As IntPtr) As IntPtr

End Function

<DllImport("VADAV.DLL", EntryPoint:="VDACQ_GetFrameDim", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)>
Public Shared Sub VDACQ_GetFrameDim(ByRef W As IntPtr, ByRef H As IntPtr)
End Sub

Collapse | Copy Code
Private Sub CheckDetectorButton_Click(sender As System.Object, e As System.EventArgs) Handles CheckDetectorButton.Click
Dim W As IntPtr
Dim H As IntPtr
VDACQ_GetFrameDim(W, H)
DimentionTextBox.Text = W.ToString + ";" + H.ToString

Me.Cursor = Cursors.WaitCursor
If VD_ConnectRestore() Then
CheckDetectorButton.BackColor = Color.Green
Else
CheckDetectorButton.BackColor = Color.Red
End If
Me.Cursor = Cursors.Default
End Sub

But with VD_GetHomeDirectory I get into hot water. Any idea please :(
mehdishahgholi 21-Oct-14 3:28am View    
I tried but does not work. Could you please explain more or write the code