Internally (e.g. for Copy Image Data) the data flavour appears to be
application/x-moz-native-image and nsIImage (which is unscriptable),
however there are places which seem to support image/jpeg|png|gif with
nsIInputStream data.
I have a PNG image in a javascript string, I tried to wrap it into a
nsIStringInputStream and copy to clipboard, but this doesn't work. I
did it this way:
var sstream = Components.classes["@mozilla.org/io/string-input-
stream;1"]
.createInstance(Components.interfaces.nsIStringInputStream);
sstream.setData(image, image.length);
var trans = Components.classes["@mozilla.org/widget/transferable;
1"]
.createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("image/png");
trans.setTransferData("image/png", sstream, sstream.available());
var clipboard = Components.classes["@mozilla.org/widget/clipboard;
1"]
.getService(Components.interfaces.nsIClipboard);
clipboard.setData(trans, null, clipboard.kGlobalClipboard);
I also tried to paste the data from clipboard after the copy. And I'm
receiving pasted data length to be 122 bytes, while copied image was
about 9Kb.
Could you suggest what I'm doing wrong? And also do you know how to
identify what's the interface of the object returned from paste? I
tried to QueryIntefrace(nsIInputStream) on pasted object, but it
fails.