Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  19] [ 5]  / answers: 1 / hits: 37145  / 10 Years ago, tue, november 4, 2014, 12:00:00

I have a canvas element with some doodling in it.



I am using the following to convert the canvas to a jpeg:



var data = canvas.toDataURL( image/jpeg, 0.5 );
var img = new Image();
img.src = data;
$( body ).append( img );


However instead of my doodle, I get a solid black jpeg.



Can anyone tell me what I'm doing wrong?



Thanks!


More From » jquery

 Answers
6

Thats happening because the JPEG does not support a transparent background.. if you want that to be supported use png (the default extension) else you can set a non transparent fill color to the canvas using .fillStyle and .fillRect


[#68915] Sunday, November 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ammonjesseg

Total Points: 170
Total Questions: 110
Total Answers: 98

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;