Jump to content
Xtreme .Net Talk

danielzee

Members
  • Posts

    1
  • Joined

  • Last visited

About danielzee

  • Birthday 02/28/1977

danielzee's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. i am a writing a program to captured a bitmap from one computer and send it to another computer on a LAN network the problem is that i alway get a prefect first bitmap pic on the picturebox on the client computer but one that follows it will be distorted with the first images i tried flushing nothing works this the server code fragment Public Sub CaptureImage() Dim data As IDataObject Dim bmap As Image '---copy the image to the clipboard--- SendMessage(hWnd, WM_CAP_EDIT_COPY, 0, 0) '---retrieve the image from clipboard and convert it ' to the bitmap format data = Clipboard.GetDataObject() If data Is Nothing Then Exit Sub If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then '---convert the data into a Bitmap--- bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image) '---save the Bitmap into a memory stream--- bmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp) '---write the Bitmap from stream into a byte array--- Image = ms.GetBuffer End If End Sub this the client code Public Function ReceiveImage() As Boolean Try Dim counter As Integer = 0 Dim totalBytes As Integer = 0 Dim bytesRead As Integer = 0 Do '---read the incoming data--- bytesRead = nws.Read(data, 0, client.ReceiveBufferSize) totalBytes += bytesRead '---write the byte() array into the memory stream--- s.Write(data, 0, bytesRead) counter += 1 'Loop Until totalBytes >= SIZEOFIMAGE Loop Until totalBytes >= SIZEOFIMAGE '---display the image in the PictureBox control--- i += 1 Select Case i Case 2 PictureBox2.Image = Image.FromStream(s) End Select PictureBox1.Image = Image.FromStream(s) PictureBox1.Refresh() nws.Flush() s.Flush() client.Close()
×
×
  • Create New...