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

Canvas toDataURL() returns empty string #490

Open
JohnKlenk opened this issue Nov 24, 2023 · 0 comments
Open

Canvas toDataURL() returns empty string #490

JohnKlenk opened this issue Nov 24, 2023 · 0 comments

Comments

@JohnKlenk
Copy link

JohnKlenk commented Nov 24, 2023

In UltraLight 1.3 (and also 1.2.1), the toDataURL() canvas function returns an empty string (does not throw exception). Here is example html to show the issue (this works in Chrome) in the UltraLight browser sample:

<html>
<body>
<div id="output"></div>
<script>
// Create a 16 x 16 canvas filled with a color
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const size = 16;
canvas.width = size;
canvas.height = size;
ctx.fillStyle = "#006575";
ctx.fillRect(0, 0, size, size);

// Call toDataURL() and GetImageData()
let output = "dataURL: " + canvas.toDataURL().length;
try {
  var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  output += " imageData: " + imageData.data.length;
} catch (error) {
  output += " imageData error: " + error;
}

// Output length of toDataURL() and GetImageData()
document.getElementById('output').textContent = output;
</script>
</body>
</html>

FYI, the getImageData() function was broken in 1.2 (and even caused a freeze if the inspector was open), but has been fixed in 1.3.

Edit: I tried using toBlob() as a workaround, but that also fails.

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

1 participant