Solved

How to read Byte by Byte From Clipboard Image data?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use closed file on desktop in vba 6 65
Sending a email via excel using vba 6 71
VBA: Select SQL query based on a config Sheet v2 11 38
Spell Check in VB6 13 96
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

911 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

24 Experts available now in Live!

Get 1:1 Help Now