Is it possible to cut and paste images in BlitzMax

BlitzMax Forums/MaxGUI Module/Is it possible to cut and paste images in BlitzMax

sswift(Posted 2009) [#1]
I've had users request the ability to drag and drop files from photoshop into my texture generator, and I've realised this is impossible, (I'm sure they're not talking about doing so from a file dialog) and that what they really want is copy and paste.

But is is possible to copy and paste images in Blitzmax? I know there is a GadgetPaste command but the documentation says nothing about what it is capable of.

If I were to copy an image to the clipboard, and then use this on a canvas, would it work?

And is that the best way of doing things if all I want to do is get access to the image data so I can process it?

And if I can do that, how can I find out exactly how large the image is before the past operation so I know how big a canvas I need?

Also, what's the best way to handle the CTRL-V thing? I seem to recall there is a way to define hotkeys to generate special events...


jsp(Posted 2009) [#2]
The last time I checked GadgetPaste, it was for text only. If I remember correctly I saw some code in the codearchive to paste images from the clipboard.

The easiest would probably to drag and drop the photoshop file onto your window. You get the path of the file and you can check if it's of correct format, size, depth and so on.
WINDOW_ACCEPTFILES = Enable drag and drop operations

For your CTRL-V you could define a hotkey or if you have a window menu it's may fine to define it there.
CreateMenu:TGadget(text$,tag,parent:TGadget,hotKey=0,modifier=0 )

You can of course also handle key presses yourself on almost any gadget. While panels and canvasses support those directly you have to switch it on for others via the SetGadgetSensitivity command.


sswift(Posted 2009) [#3]
Well I found this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=2148

But that only works on Win32, and apparently only sometimes. I need something that will work reliably and on macs as well.


jsp(Posted 2009) [#4]
Crossplatform is not that simple, also the format stored in the clipboard is not always the same.
Maybe try this from the german forum for windows:
http://www.blitzforum.de/forum/viewtopic.php?t=15653&highlight=clipboard

http://developer.gimp.org/api/2.0/gtk/gtk-Clipboards.html

http://developer.apple.com/mac/library/samplecode/PasteboardPeeker/listing1.html

A module would be nice;)