Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Add pasteImage API to handle paste image #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add pasteImage API to handle paste image #138

wants to merge 1 commit into from

Conversation

hfcorriez
Copy link

The API will return BASE64 string format of Image. You can add "data:image/png;base64," prefix and set to src attribute, it will be shown as html5 data uri image.

If you want to mock a html5 File Object to upload or do some other things. There is the code:

var imgData = window.macgap.clipboard.pasteImage();
if (!imgData) return;
var byteString = window.atob(imgData);
var ia = new Uint8Array(byteString.length);
for (var i = 0; i < byteString.length; i++) {
  ia[i] = byteString.charCodeAt(i);
}
var file = new Blob([ia], {type: 'image/png', encoding: 'utf-8'});

@hfcorriez
Copy link
Author

@ifavo This is the PR you want.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant