# Re: 急！如何将存放在阵列中的资料（bitmap）,show在萤幕上呢？

Posted by knight on December 16, 1998 at 10:16:48:

In Reply to: Re: 急！如何将存放在阵列中的资料（bitmap）,show在萤幕上呢？ posted by 科南 on December 16, 1998 at 10:09:02:

: : :
: : : 小弟的构想：将server端的画面传送给client端

: : : 先将萤幕的画面抓取再放到阵列中传送
: : : 但是
: : : '将该图全放进ByteAry中
: : : res = GetBitmapBits(hBitmap, totbyte, byteAry(0))

: : : 如何在client端将收到的资料又show到萤幕上呢？

: : 用setbitmapbits(hbitmap,totbyte,byteary())

: 我有试过，可是show不出来？
: 是不是我show的程式写错了？
: 您是否可以demo一个小弟！感激不尽
Option Explicit
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Sub Command1_Click()
Dim res As Long
Dim byteAry() As Byte
Dim byteAry1() As Byte
Dim byteAry2() As Byte
Dim Data1 As Byte
Dim Index3 As Long
Dim Index4 As Long
Dim Index1 As Long
Dim Index2 As Long
Dim totbyte As Long, i As Long
Dim Devmodeset As DEVMODE
Dim Screenhdc As Long
Dim Rval As Long
Dim X1&, X2&, X3&, X4&, Y1&, Y2&, Y3&, Y4&
X1 = 0: Y1 = 0: X2 = 640: Y2 = 480
X3 = 0: Y3 = 0: X4 = 640: Y4 = 480
Screenhdc = CreateDC("display", "", "", Devmodeset)
Rval = StretchBlt(Picture1.hdc, X1, Y1, X2, Y2, Screenhdc, X3, Y3, X4, Y4, &HCC0020)
Rval = DeleteDC(Screenhdc)
Picture1.Refresh
totbyte = X2 * Y2 '总共要多少个Byte来存图
ReDim byteAry(totbyte) '将该图全放进ByteAry中
'ReDim byteAry1(totbyte) '将该图全放进ByteAry中
'ReDim byteAry2(totbyte) '将该图全放进ByteAry中
res = GetBitmapBits(Picture1.Image, totbyte, byteAry(0))
Index2 = 0
Data1 = 0
Command1.Caption = "AAAA"
For Index1 = 0 To totbyte - 1
If byteAry(Index1) = byteAry(Index1 + 1) And Data1 <> 255 Then
Data1 = Data1 + 1
Else
ReDim Preserve byteAry1(Index2 + 1)
byteAry1(Index2) = Data1
Index2 = Index2 + 1
byteAry1(Index2) = byteAry(Index1)
Index2 = Index2 + 1
Data1 = 0
End If
Next
Command1.Caption = "PPPP"
Index4 = 0
For Index1 = 0 To Index2 - 1 Step 2
ReDim Preserve byteAry2(Index4 + byteAry1(Index1) + 1)
For Index3 = 0 To byteAry1(Index1)
byteAry2(Index4 + Index3) = byteAry1(Index1 + 1)
Next
Index4 = Index4 + byteAry1(Index1) + 1
Next
Command1.Caption = "ZZZZ"
res = SetBitmapBits(Picture2.Image, totbyte, byteAry2(0))
Picture2.Refresh
End Sub

Private Sub Picture2_Click()

End Sub
以上程式是我测试时写的
还加上了简单的压缩
我有写过一个类似的程式
有问题再提出来讨论

Follow Ups:

- Re: 急！如何将存放在阵列中的资料（bitmap）,show在萤幕上呢？ 科南 13:54:26 12/16/98 (0)