Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / read image from clipboard?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Jul 2012 09:47
Hey everyone


Is there any way to read an image stored in the clipboard? It doesn't have to be converted to an image, I'd already be satisfied if I had the pixel data stored in an array.

TheComet

GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 2nd Jul 2012 18:05
First let me disqualify my answer... About two months tinkering with DBPro last summer, and on day 2 of this summer...

I'd hit up the windows API...

The function calls you want are in User32.dll, here is their
[href=http://msdn.microsoft.com/en-us/library/windows/desktop/ff468802(v=vs.85).aspx
]reference
[/href]... I know DBPro has a method to invoke system DLL's I just don't know what it is. Basically you will have to make stubs for all the various clipboard functions you use.

1. It looks like you will have to open a handle to the clipboard
2. Enumerate the clipboard formats
3. Make sure the data on the clipboard is in a format that you want
4. allocate memory in your application to take the clipboard data
5. load the data from the clipboard to your application...
6. Parse your data to make sure it is in a format that DBPro likes... I am sure you will need to convert it from a GDI friendly format to a DirectX friendly format...
7. Safely release all of the various handles you have opened to that you don't eventually crash User32.DLL...

Then spend about three weeks debugging (without the aid of a windows api debugger...) the whole thing so that Your application doesn't crash and burn.

I really hope someone can provide a better solution than I did...
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 2nd Jul 2012 18:32
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Jul 2012 19:15
I have searched the command list and could not find a command that could get an image from the clipboard.

TheComet

basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 2nd Jul 2012 19:29 Edited at: 13th Jul 2012 13:19
@theCommet:

Sorry, I always though this pluggin allows you to get clipboard image. but never used it myself.

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 3rd Jul 2012 01:01 Edited at: 3rd Jul 2012 01:02
This should do what you need.
The test code waits until the clipboard contains an image, grabs it and then displays it. Only certain formats work.

edit: Requires matrix1utils

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Jul 2012 04:13 Edited at: 3rd Jul 2012 04:13
Quote: "This should do what you need.
The test code waits until the clipboard contains an image, grabs it and then displays it. Only certain formats work.

edit: Requires matrix1utils"


didn't work for me...

EDIT

FTR Win7x64

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 3rd Jul 2012 10:51
Quote: "didn't work for me...

EDIT

FTR Win7x64"


Strange, I have Win7x64, but I also use Win7 32 & XP 32 which it also works on. Does it compile & run at all? Does it ever detect a picture is in the clipboard? Have you the latest matrix1utils installed?
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Jul 2012 14:48
It runs and compiles... But does not capture the clipboard images...

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 3rd Jul 2012 16:17
Quote: "It runs and compiles... But does not capture the clipboard images..."


Just out of curiousity, where are you cut/copying your image from? I tested various bitmaps from google image search, websites, Paintshop Pro 8 & even copying a rectangle from MS Paint and it captured it successfully.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Jul 2012 16:39
Will give that a go later... But I tested against local images on Disk (My Pictures)

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Jul 2012 17:44 Edited at: 3rd Jul 2012 18:03
Quote: "This should do what you need."


Yes That works. I just added the Width, and Height to it. I found that I had to make the image twice, else set display mode deletes it.



sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 3rd Jul 2012 18:01
Quote: "Is there a way to get the width, and Height?"


The function copies the data as a standard DBPro image memblock, so the width & height are stored at the beginning of the memblock. You can retrieve them by reading the first 2 dwords:



Alternatively, since the example converts the memblock to an image to paste it, you could just use `image width` and `image height`.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 4th Jul 2012 15:53
ah yeah tested again and it works for browsers but not for Windows... but only the one image brag was there supposed to be continuous feed?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 4th Jul 2012 16:10 Edited at: 4th Jul 2012 16:15
Do you mean Double Buffering? I don't think that the clipboard image is the Double Buffer image. I press PrtScn to get a Clipboard Image. Although some Codecs seem to send video to the clipboard. Then you get video in photoshop, which makes capturing the images difficult.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Jul 2012 18:11
@MrValentine
If you copy an image from windows explorer you get a file in the clipboard not an image.

[b]
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 4th Jul 2012 18:27


I should have thought of that... Proves how tired I am lately...

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Jul 2012 13:18
Fantastic, thanks a lot for the example and help!

TheComet

Login to post a reply

Server time is: 2026-07-07 15:11:37
Your offset time is: 2026-07-07 15:11:37