Click here to Skip to main content
15,851,701 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have some code I converted from C# but VB cant handle the pointers and I could not fix it using the intPtr.
Cloud someone please fix it or help me fix it.
Public Function Displayimage(image As Integer(,)) As Bitmap
    Dim i As Integer, j As Integer
    Dim output As New Bitmap(image.GetLength(0), image.GetLength(1))
    Dim bitmapData1 As BitmapData = output.LockBits(New Rectangle(0, 0, image.GetLength(0), image.GetLength(1)), ImageLockMode.[ReadOnly], PixelFormat.Format32bppArgb)
    Dim imagePointer1 As Pointer(Of Byte) = CType(bitmapData1.Scan0, Pointer(Of Byte))
    For i = 0 To bitmapData1.Height - 1
        For j = 0 To bitmapData1.Width - 1
            imagePointer1(0) = CByte(image(j, i))
            imagePointer1(1) = CByte(image(j, i))
            imagePointer1(2) = CByte(image(j, i))
            imagePointer1(3) = 255
            '4 bytes per pixel
            imagePointer1 += 4
        'end for j
        '4 bytes per pixel
        imagePointer1 += (bitmapData1.Stride - (bitmapData1.Width * 4))
        'end for i
    'end unsafe
    Return output
    ' col;
End Function
Wendelius 14-May-12 16:50pm    
You didn't specify the exact problem. Could you post the C# equivalent so it would be easier to see original situation
Sergey Alexandrovich Kryukov 14-May-12 17:01pm    
Where did you find pointers used in C#? They only can appear in unsafe mode. Can you show that code? What should it do and why pointers?
Don't you mix up pointers with references (reference pointers, managed pointers)?
What's the problem?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900