如何把图片转换成16进制数据,用一个变量来获取这些数据,最好是有一个控件或函数可以把转换后的数据输出来。还有能不能从数据里或图片中把色素提取出来。

解决方案 »

  1.   

    '将图片转化为long数组
    Dim pic as picturebox
    Function change() as long()
        on error resume next
        Dim i as Long
        Dim ii as Long
        Dim height as long
        dim width as long
        height=pic.image.height
        width=pic.image.width
        dim points(height\15,width\15) as long
        For i=0 to height step 15 '以像素为单位
            for ii=0 to width step 15 
                points(i/15,ii/15) =pic.point(i/15,ii/15)
            next
        next
        change=points
    End Function 
    ------------------------------------------------------------------------------------
    将long数据转化为rgb色素
    '首先定义类型RGB
    Type rgb
    r As Integer
    g As Integer
    b As Integer
    End Type
    '函数
    Function unrgb(ByVal Color As Long) As RGB
        unrgb.R = (Color And &HFF)
        unrgb.G = (Color And 62580) / 256
        unrgb.B = (Color And &HFF0000) / 65535
    End Function
      

  2.   

    用Point方法来操作象素是相当没有效率的做法。
    可以考虑使用GDI提供的函数。'声明API
    Private Declare Function GetBitmapBits Lib "gdi32" Alias "GetBitmapBits" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As LongDim Pic as StdPicture
    Dim Size as LongDim Array1() as Byte  '要装入的数组Dim back as Long   '接受返回值Size=Width*Height*Bpp   '图像大小=宽度×高度×颜色深度Redim Array1(0 to Size-1) as Byteback=GetBitmapBits(Pic.handle,Size,Array(0)) '获取象素数据if back=0 then Msgbox "Error!"  '如果返回0则表明出错。
      

  3.   

    哦笔误,倒数第二行那个Array应该是Array1。