The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Put SDL_Surface in clipboard
dandago


Joined: 30 Aug 2013
Posts: 34
Is there any recommended way to copy an SDL_Surface * to clipboard? I see there are clipboard functions for UTF8 text, but how are other types to be handled?
Put SDL_Surface in clipboard
Bob Rubbens
Guest

From a quick google it seems that SDL only has clipboard functions related to txt. Furthermore, another google tells me that to handle image data in the clipboard you'll need to set some data flags to tell the OS that there's an image on the clipboard (on windows, at least). SDL probably sets the clipboard flags to text, so you'll probably have to write some platform specific code for this, or extend SDL (this is all a wild guess though so don't take my word for it).

There is one exception though: if you want to exchange data between two of your own applications using the clipboard. Then I would probably just convert the chararray in the surface to base64 or something, prefix it with a magic string, and then just put that in the clipboard. The other application can then just recognize it's a dandango-type textual image, and interpret the base64 string accordingly. A naïve solution, but it probably works.


On 18 January 2016 at 08:41, dandago wrote:
Quote:
Is there any recommended way to copy an SDL_Surface * to clipboard? I see there are clipboard functions for UTF8 text, but how are other types to be handled?



Daniel D'Agostino
http://gigi.nullneuron.net/gigilabs/


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Put SDL_Surface in clipboard
Eric Wing
Guest

On 1/18/16, Bob Rubbens wrote:
Quote:
From a quick google it seems that SDL only has clipboard functions related
to txt. Furthermore, another google tells me that to handle image data in
the clipboard you'll need to set some data flags to tell the OS that
there's an image on the clipboard (on windows, at least). SDL probably sets
the clipboard flags to text, so you'll probably have to write some platform
specific code for this, or extend SDL (this is all a wild guess though so
don't take my word for it).

There is one exception though: if you want to exchange data between two of
your own applications using the clipboard. Then I would probably just
convert the chararray in the surface to base64 or something, prefix it with
a magic string, and then just put that in the clipboard. The other
application can then just recognize it's a dandango-type textual image, and
interpret the base64 string accordingly. A naïve solution, but it probably
works.

On 18 January 2016 at 08:41, dandago wrote:

Quote:
Is there any recommended way to copy an SDL_Surface * to clipboard? I see
there are clipboard functions for UTF8 text, but how are other types to
be
handled?



This was my SDL_Clipboard prototype/proposal which included handling
image copy-and-pasting SDL_surfaces between native platform image
types. I never figured out or got help on the X11 backend though, so
it only works on Mac and Windows.
http://playcontrol.net/ewing/jibberjabber/SDL_ClipboardPrototype.html

Maybe you can update it and finish it for SDL 2.0. (iOS and Android
backends should also be added which speaks to how old this thing is.)

Thanks,
Eric
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org