Solved

How to read Byte by Byte From Clipboard Image data?

Posted on 1998-05-09
4
951 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
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Then calculate the size as you capture it!?
0
 

Author Comment

by:msali
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now