4 messages in org.mozilla.lists.dev-extensionsRe: copy image to clipboard
FromSent OnAttachments
telegaOct 27, 2007 12:38 am 
NeilOct 27, 2007 8:03 am 
telegaOct 27, 2007 12:31 pm 
NeilOct 27, 2007 4:23 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: copy image to clipboardActions...
From:telega (tel@gmail.com)
Date:Oct 27, 2007 12:31:21 pm
List:org.mozilla.lists.dev-extensions

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.