PDA

View Full Version : Accessing the Windows Clipboard



AntonyScerri
04-14-2006, 01:37 PM
Hi

One of my plugins (UV Imaginator) currently generates images saving them to disk. I want to know if there is a standard way within the Lightwave SDK for copying the image data to the Windows clipboard so it can be pasted into other painting packages? I have had a look but not seen anything obvious.

If there isnt, my next question is; will writing an ImageSaver that copies the data into a BMP structure (or equivalent) and places that into the Windows clipboard using Win32 APIs be the easiest/neatest method of getting at the image data I have created. Alternatively i could create and write to a windows BMP structure directly, but then have to write code to switch between what needs to be drawn on.

Tony

Lightwolf
04-14-2006, 02:48 PM
There is no clipboard functionality within the SDK.
The easiest way would probably be a Generic Plugin that displays a (pop-up)list of all images loaded into LW and copies the selected one.
Check out the Image List and Image Utility globals in the SDK.
Unfortunately Generics are Layout only, you might be able to do the same thing from Modeler using a CommandSequence plugin.
Of course, you will have to create the bmp and paste to the clipboard in your own code using the Windows APIs. (Does the clipboard actually support alpha channels now?)
Cheers,
Mike

Lightwolf
04-14-2006, 03:11 PM
This might get you started on the windows side of things:
http://www.codeproject.com/clipboard/clipnutshell.asp
http://www.codeguru.com/Cpp/G-M/opengl/article.php/c2711

Actually, this should be really useful.

Cheers,
Mike

AntonyScerri
04-16-2006, 03:59 AM
Thanks I'l take a look at those links, might have seen one already. There are various image formats the windows clipboard will support not sure if any of those inherently support alpha channels or not. I dont have to worry about that because im just producing a 24 bit RGB image, using the image utils already. I figured building an image saver plugin would simply allow me to specify that to the image save call and that can then take care of copying it to the clipboard. I want to make it a direct call from my modeler plugins UI rather than a separate set of actions from the user. I can always enumerate every pixel in the image buffer myself and build the bitmap to put into the clipboard but figured an image saver would be more effecient.

Thanks

Tony

AntonyScerri
04-16-2006, 05:42 AM
The Windows clipboard API was pretty straightforward, already had most of the code done, so finished that off. Looking at the SDK a bit more i figured the Image Saver was a bad idea, mixing concepts too much. So im left with either doing it within my plugin code directly (currently my preffered choice) or i could write a Global plugin to make the Windows Clipboard copy and paste functions available to other plugins also for certain data types.

For now im just going to put it all within my plugin just as a function I can call. I may look at writing it into a Global plugin later on.

Tony