第一个问题,我如何能对比两个DC的内容是否一致?
第二个问题,我想把DC和一段Byte数组互相拷贝,使用CopyMemory怎么办?我想不会是使用hDC来做罢?
想法是这样的,我想copy下来屏幕DC,然后分割成小区域,
判断哪个区域发生变化,那么把这个区域转化为二进制从网络传递出去。

解决方案 »

  1.   

    jlum99(闲人) 
    谢谢你的提议,
    那么不知道你有没有你所说的在内存中压缩图像的函数,或者算法?
    不能变成文件压,因为不断的磁盘操作会很慢。
      

  2.   

    第一个问题,我如何能对比两个DC的内容是否一致?两个DC的内容是否一致,如何界定,看其数据是否一致?第二个问题,我想把DC和一段Byte数组互相拷贝,使用CopyMemory怎么办?我想不会是使用hDC来做罢?用不着CopyMemory,用GetBitmapBits 和setBitmapBits 即可:'Create a new project, add a command button and a picture box to the project, load a picture into the picture box.
    'Paste this code into Form1
    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 GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
    Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
    Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
    Dim PicBits() As Byte, PicInfo As BITMAP, Cnt As Long
    Private Sub Command1_Click()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'Get information (such as height and width) about the picturebox
        GetObject Picture1.Image, Len(PicInfo), PicInfo
        'reallocate storage space
        ReDim PicBits(1 To PicInfo.bmWidth * PicInfo.bmHeight * 3) As Byte
        'Copy the bitmapbits to the array
        GetBitmapBits Picture1.Image, Ubound(PicBits), PicBits(1)
        'Invert the bits
        For Cnt = 1 To Ubound(PicBits)
            PicBits(Cnt) = 255 - PicBits(Cnt)
        Next Cnt
        'Set the bits back to the picture
        SetBitmapBits Picture1.Image, Ubound(PicBits), PicBits(1)
        'refresh
        Picture1.Refresh
    End Sub
    想加快速度的话就用 与设备无关的位图(dib)
      

  3.   

    JEPG是基于流的,应该可以满足你在内存中压缩的要求.
      

  4.   

    谢谢各位的建议,
    jlum99(闲人) 
    jpeg当然可以满足我的要求,我也想用啊,可是你有好的算法吗?呵呵,发这个贴子我是一时好奇,想知道如何拷贝DC的内容到一个数组啊,
    难道只是传递给copymemory它的hDC,我想不会。
    所以还是要问怎么copymemory啊。
    呵呵,传递图像只不过是原来的目的~
      

  5.   

    在硬盘上压缩Jpeg目前都要依赖Inter的dll,没人用VB写过Jpeg的压缩算法吗???
    还有基于流不能与每一部分都等价,文件头部信息需要另行处理
      

  6.   


    http://expert.csdn.net/Expert/topic/2072/2072641.xml?temp=.2021143
      

  7.   

    纯VB实现BMP2Jpghttp://expert.csdn.net/Expert/topic/2072/2072641.xml?temp=.2021143