IMCLIPBOARD behaves very much like MATLAB's "CLIPBOARD" function, but it works on image data. You can paste image data from the clipboard to a MATLAB array, and copy MATLAB image data to the clipboard.
IMCLIPBOARD('copy', IMDATA) sets the clipboard content to the image represented by IMDATA. IMDATA must be MxN grayscale (double, uint8, uint16), MxN black and white (logical), MxNx3 true color (double, uint8, uint16)
IMCLIPBOARD('copy', X, MAP) sets the clipboard content to the image data represented by indexed image X with colormap MAP. X must be MxN matrix (double, uint8, uint16) and MAP must be Px3 (double).
IMDATA = IMCLIPBOARD('paste') returns the current image content in the clipboard as a true color image (MxNx3 uint8).
[X, MAP] = IMCLIPBOARD('paste') returns the current image content in the clipboard as an indexed color image.
IMCLIPBOARD('paste') displays the image in a new figure window.
[...] = IMCLIPBOARD('paste', FILENAME) saves the image as FILENAME. FILENAME must be a name to one of the following image formats: JPG, GIF, BMP, PNG, TIF.
Note: IMCLIPBOARD requires Java on all platforms.
This is great in Windows, indeed. Does anyone have this working on OS X? I'm attempting to modify it for OS X... it appears to get the clipboard object but it's unhappy about getData. Help is appreciated! Thanks.
This no longer works in R2015b. A fix has been posted at:
Perfect tool for automatically moving images to the clipboard so that they can be copied into Word etc.
Matlab's default Figure > Copy option is vastly improved witht he following,
imclipboard('copy', export_fig('r', 190, 'format', 'png'));
This is useful for copying a figure into Outlook or Word.
[credit for this solution to by Oliver Woodford not me! http://mathworks.com/matlabcentral/answers/21962-export-figure-to-microsoft-outlook]
Whoops - the problem was with how I was calling it. It works great from within a GUI as well. I'm using it to copy an image of my GUI to the clipboard. This function gives a nicer image than print(gcbf, '-dmeta').
It does what it says. However, when I call it from within a GUI, the next callback that is activated (by changing a number in a text box or clicking a button), does not execute. As an example, I get the following warning for my GUI called ProductViewer. I can generate a similar error by activating any control in the GUI.
Warning: Error occurred while evaluating listener callback.
> In graphics\private\clo at 83
In cla at 29
In newplot>ObserveAxesNextPlot at 125
In newplot at 74
In imagesc at 21
In ProductViewer>PlotFrame at 629
In ProductViewer>edit_row_min_Callback at 514
In gui_mainfcn at 96
In ProductViewer at 87
Fixed java error that many have mentioned in the comments.
Updated copyright in Java code.