那位帮忙给出完整程序,本人对编程一窍不通,而又急于用此作论文。先谢了!

解决方案 »

  1.   

    网上好多例子
    到这里去下一个,
    http://www.21code.com/codebase/?pos=list&type=subclass&mainclass=1&subclass=13
      

  2.   

    '用这段代码看看是不是把你的picture1中的图像变成红色了!
    '事先图片框中一定要有图片,不然会出错的
    '在VB中只有描拟指针了,其它还没想到有什么好的办法
    '注意bmp图像数据是BGR这样的,而不是RGB,并且是从下到上
    Private Type SAFEARRAYBOUND
        cElements As Long
        lLbound As Long
    End Type
    Private Type SAFEARRAY1D
        cDims As Integer
        fFeatures As Integer
        cbElements As Long
        cLocks As Long
        pvData As Long
        Bounds(0 To 0) As SAFEARRAYBOUND
    End Type
    Private Type SAFEARRAY2D
        cDims As Integer
        fFeatures As Integer
        cbElements As Long
        cLocks As Long
        pvData As Long
        Bounds(0 To 1) As SAFEARRAYBOUND
    End Type
    Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    Private Type BITMAP
        bmType As Long
        bmWidth As Long
        bmHeight As Long
        bmWidthBytes As Long
        bmPlanes As Integer
        bmBitsPixel As Integer
        bmBits As Long
    End Type
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Const SRCCOPY = &HCC0020 '
    Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
    Dim bm As BITMAP
    Dim sa As SAFEARRAY1D
    Dim arrpicdata() As Byte                    '图像数据Private Sub Command1_Click()
        Dim lb1 As Long
        Dim lb2 As Long
        Dim ub1 As Long
        Dim ub2 As Long
        Dim i As Long
        Dim j As Long
        On Error Resume Next
        GetObjectAPI Picture1.Picture, Len(bm), bm
        With sa
            .cbElements = 1
            .cDims = 1
            .Bounds(0).cElements = bm.bmWidthBytes * bm.bmHeight
            .Bounds(0).lLbound = 0
            .pvData = bm.bmBits
        End With
        CopyMemory ByVal VarPtrArray(arrpicdata), VarPtr(sa), 4             '描拟指针
        lb1 = LBound(arrpicdata)
        ub1 = UBound(arrpicdata)
    '    lb2 = LBound(arrpicdata, 2)
    '    ub2 = UBound(arrpicdata, 2)
        If Err.Number <> 0 Then
            MsgBox "读取图像数据出错!", vbInformation
            CopyMemory VarPtrArray(arrpicdata), ByVal 0&, 4
            Exit Sub
        End If
        For i = lb1 To ub1 Step 3
                arrpicdata(i) = 0
                arrpicdata(i + 1) = 0
                arrpicdata(i + 2) = 255
        Next
        CopyMemory ByVal VarPtrArray(arrpicdata), 0&, 4         ' 释放指针
        Picture1.Refresh
    End Sub
      

  3.   

    Dim arrpicdata() As Byte                    '图像数据
    数据就在上面那数组里面了!
      

  4.   

    不明白你的什么对数转换,给我发邮件吧
    [email protected]