B4J Question Clipboard Image to file

prokli

Active Member
Licensed User
Longtime User
Hello!
Does anybody know how to read an Image located in clipboard to a file?

I use this code which seems to work well, but when I try to Show/open this file (e.g. in Paint or windows picture viewer) the file does not keep the image (keeps just white/blank area).

Dim clipImage As Image
Dim Out As OutputStream

If fx.Clipboard.HasImage Then
Out = File.OpenOutput(File.DirApp, "tmp.png", False)
clipImage = fx.Clipboard.GetImage
clipImage.WriteToStream(Out)
Out.Close
End IF
 

Daestrum

Expert
Licensed User
Longtime User
Are you copying the image from inside a paint program ?
If you use copy, inside a graphics program ie, paint , you just get the background as you describe.
Odd thing is, if you right click an image on a web page, like your profile picture, and select copy, then it works fine and shows the image.
 
Last edited:
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Sorry, but I am not sure what you are telling me?!
Inside a word document, I select a picture then I press the right mouse button and select copy (to clipboard). Instead of using the mouse button I sometime press "Ctrl" + "C" keys which does the same. When I select the picture inside the windows explorer, I will see the picture content as a preview on the left lower side of the explorer. But whenever I open this "PNG" file it is still blank .
Thx for further help!

Harald
 

Attachments

  • explorer view.png
    explorer view.png
    89.7 KB · Views: 288
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Hello Erel,

it took me some hours to find out, how I can deal with images in clipboard. First of all, if I select a picture inside a word document, then click right mouse button and select "copy" (there is no "copy picture") then the "fx.Clipboard.HasImage" becomes TRUE. The code as shown in previous post generates and forwards a file to my android device. The file has a certain length but it shows nothing (sometimes black, sometimes white). Now, when I copy an image from Google explorer (right mouse button then press "copy picture") a file is created, transferred to android device, it keeps a certain length and -- it shows the Image!!!--. When I use Internet Explorer 11 there is no "Copy picture" and therefore it does not work. So, it seems that it depends on how I copy pictures to clipboard
 
Upvote 0

alienhunter

Active Member
Licensed User
Longtime User
Hello Erel,

it took me some hours to find out, how I can deal with images in clipboard. First of all, if I select a picture inside a word document, then click right mouse button and select "copy" (there is no "copy picture") then the "fx.Clipboard.HasImage" becomes TRUE. The code as shown in previous post generates and forwards a file to my android device. The file has a certain length but it shows nothing (sometimes black, sometimes white). Now, when I copy an image from Google explorer (right mouse button then press "copy picture") a file is created, transferred to android device, it keeps a certain length and -- it shows the Image!!!--. When I use Internet Explorer 11 there is no "Copy picture" and therefore it does not work. So, it seems that it depends on how I copy pictures to clipboard



i had the same problem until i found this , yeah it is weird thing even screen copy software will not work properly , the only one that is working is "jing"
http://www.techsmith.com/jing.html
or windows screen copy
 
Upvote 0
Top