代码之家  ›  专栏  ›  技术社区  ›  addohm

无法为结构intptr编制索引,因为它没有默认属性

  •  0
  • addohm  · 技术社区  · 7 年前

    code snippet from this answer 在VB函数中,我遇到了一个以前从未见过的障碍。 我没有找到足够的细节,所以我在以太中寻找智慧。

    Private Shared Function ConvertImage(filepath As String) As String
        Dim bmp As Bitmap = New Bitmap(filepath)
        Dim v As Byte = &HAA
        ' Lock the bitmap's bits. 
        Dim bmpData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), Imaging.ImageLockMode.ReadWrite, Imaging.PixelFormat.Format1bppIndexed)
        Try
            Dim pBuffer As IntPtr = bmpData.Scan0
            For r As Integer = 0 To bmpData.Height Step 1
                Dim row As IntPtr = pBuffer + r * bmpData.Stride
                For c As Integer = 0 To bmpData.Stride Step 1
                    row(c) = v
                Next
            Next
    
        Catch ex As Exception
        Finally
            bmp.UnlockBits(bmpData)
        End Try
        filepath = IO.Path.GetTempPath & "label.bmp"
        bmp.Save(filepath)
    End Function
    

    row(c) = v . 我需要做什么来解决这个问题?

    0 回复  |  直到 7 年前