VB和指针:有问题 [英] VB and Pointers: Having problems

查看:130
本文介绍了VB和指针:有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码是从C#转换而来的,但是VB无法处理指针,而且我无法使用intPtr对其进行修复.
云某人,请修复它或帮助我修复它.

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
        Next
        'end for j
        '4 bytes per pixel
        imagePointer1 += (bitmapData1.Stride - (bitmapData1.Width * 4))
        'end for i
    Next
    'end unsafe
    output.UnlockBits(bitmapData1)
    Return output
    ' col;
End Function

推荐答案

这些工具也可能会有所帮助:
- http://converter.telerik.com/ [ ^ ]
- http://www.developerfusion.com/tools/convert/csharp-to-vb/ [^ ]
- http://www.carlosag.net/tools/codetranslator/ [
These tools might also be helpful:
- http://converter.telerik.com/[^]
- http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
- http://www.carlosag.net/tools/codetranslator/[^]


这篇关于VB和指针:有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆