Solved

How to read Byte by Byte From Clipboard Image data?

Posted on 1998-05-09
4
963 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

809 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