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

Data URI generates a black gif #17

Closed
kinduff opened this issue Jun 19, 2014 · 4 comments
Closed

Data URI generates a black gif #17

kinduff opened this issue Jun 19, 2014 · 4 comments

Comments

@kinduff
Copy link

kinduff commented Jun 19, 2014

If I add a frame with a Data URI it generates a black gif.

To reproduce

Modify clock.html demo at line 127:

uridata = canvas.toDataURL('image/png');
encoder.addFrame(uridata, true);

Data URI is generated good, you can see it if you add console.log(uridata) and the end.

Did I missed something from the docs, tho?

@antimatter15
Copy link
Owner

You can't add raw image URLs with addFrame which expects a canvas object. One way to do this is by creating a canvas context and calling drawImage with the data URL

Sent from my iPhone

On Jun 19, 2014, at 11:12 AM, kinduff notifications@github.com wrote:

If I add a frame with a Data URI it generates a black gif.

To reproduce

Modify clock.html demo at line 127:

uridata = canvas.toDataURL('image/png');
encoder.addFrame(uridata, true);
Data URI is generated good, you can see it if you add console.log(uridata) and the end.

Did I missed something from the docs, tho?


Reply to this email directly or view it on GitHub.

@kinduff
Copy link
Author

kinduff commented Jun 19, 2014

@antimatter15 I read at the README file that:

You can set the second parameter to true and pass a imageData.data-esque array as your first argument.

How can I generate this imageData.data-esque?

@leeoniya
Copy link

my guess is

var fauxImageData = {
    width: 320,
    height: 75,
    data: [...],                      // `Uint8Array` or `Uint8ClampedArray` of subpixels
};

@kinduff
Copy link
Author

kinduff commented Jul 7, 2014

@leeoniya Thanks!

@kinduff kinduff closed this as completed Jul 7, 2014
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

No branches or pull requests

3 participants