Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant