Domanda

I am building a xpcom component with JS. I have got the clipboard data in JS, when the data type is image/png, I want to get its base64 string, my code is:

        ......
        trans.addDataFlavor('image/png');
        clipboard.getData(trans, Services.clipboard.kGlobalClipboard);
        trans.getTransferData('image/png', str, strLength);
        let mw = Services.wm.getMostRecentWindow("navigator:browser");

        data.data = str.value.QueryInterface(Ci.nsISupportsCString).data;
        data.data = mw.btoa(data.data);
        ...

I can get the base64 string under Linux, but when I run my code in windows, I got an error: NS_NOINTERFACE: Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface]

data.data = str.value.QueryInterface(Ci.nsISupportsCString).data; I do not konw how the get the base64 string of the image data in my xpcom component, who can give me an answer?

È stato utile?

Soluzione

Apparently images are stored to clipboard differently across platforms. Check how Jetpack reads them.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top