?
Solved

How to read Byte by Byte From Clipboard Image data?

Posted on 1998-05-09
4
Medium Priority
?
980 Views
Last Modified: 2008-02-01
Hi experts,
I have stored an image in clipboard.  Now i want to read the image byte by byte so that i can break it into pieces and send it over the tcp/ip based network to another station, where this station will re-assamble the data and display it in its image box or picture box.

Thanks in advance
0
Comment
Question by:msali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 200 total points
ID: 1444729
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal numBytes As Long)

Dim bytPic() As Byte

Private Sub Form_Load()
    Dim lSize  As Long
    Dim picCur As Variant
   
    Clipboard.Clear ' Clear Clipboard.
    Clipboard.SetData LoadPicture("c:\windows\FOREST.BMP")
    picCur = Clipboard.GetData(vbCFBitmap)
   
    lSize = FileLen("c:\windows\forest.bmp")
    ReDim Preserve bytPic(0 To lSize - 1) As Byte
   
    Call CopyMemory(ByVal VarPtr(bytPic(0)), ByVal VarPtr(picCur), lSize)
   
End Sub

0
 

Author Comment

by:msali
ID: 1444730
Thanks for the example but in this case u are reading the filesize from the disk.  In my project i have captured the image using bitblt and do not want to save it since saving the file i.e., disk I/O is slow.  I will be capturing the image in a timer event so lots of images in maybe 5-10 to 15 seconds of time.

waiting for a reply.
thanks a mil
regards,
msa.
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1444731
Then calculate the size as you capture it!?
0
 

Author Comment

by:msali
ID: 1444732
Dear anthonyc,
This is exactly the problem i am facing.  I do not know how to address the memory (DC).  That is why i tried to place the img in the clipboard - assuming i might be able to access the clipboard memory.  Listed below is the code of my cliping the image:

Sub CopyScreen(canvas As Object)
    Dim screendc&
   
    canvas.AutoRedraw = True
    screendc = CreateDC("DISPLAY", "", "", 0&)
    tempLong = StretchBlt(canvas.hdc, 0, 0, Screen.Width, Screen.Height, screendc, 0, 0, Screen.Width, Screen.Height, SRCCOPY)
    tempLong = DeleteDC(screendc)
    canvas.AutoRedraw = False
   
End Sub

Private Sub Timer1_Timer()
    CopyScreen Me
    Me.Caption = "Icu Uc Me - " & Counter
    Counter = Counter + 1
End Sub

regards,
msa.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question