I'm stuck with no clues how to copy image to clipboard. My code looks like this:
var image = "data:image/png;base64,..."
var io = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var channel = io.newChannel(image, null, null);
var input = channel.open();
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("image/png");
trans.setTransferData("image/png", input, input.available());
var clipid = Components.interfaces.nsIClipboard;
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
clip.setData(trans, null, clipid.kGlobalClipboard);
As Neil already noted in the newsgroup, the data expected for an image is an
nsIContainer
instance rather than a stream. I couldn't find any examples of doing that on the web so I modified your code:For me this copies the image to clipboard correctly.