모든 캔버스 이름을로드하고 나는 로컬 스토리지로, 나는이 HTML
.thanks저장 로컬 저장소에 캔버스와 나는 캔버스 이미지가
var img = new Image();
\t //Wait for image to load before doing something with content
\t img.onload = function() {
\t var canvas = document.querySelectorAll("canvas[name=myCanvas]");
\t \t for (var i = 0; i < canvas.length; i++) {
\t canvas[i].getContext("2d").drawImage(img,10,10);
}
\t };
\t img.src = 'http://i.imgur.com/VdXQ7z6.png';
localStorage.setItem("img", img);
<p>Image to use:</p>
<img id="scream" onload="draw(this)" src="http://i.imgur.com/VdXQ7z6.png" alt="The Scream" width="220" height="277">
<p>Canvas:</p>
<canvas name="myCanvas" width="250" height="300" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<canvas name="myCanvas" width="250" height="300" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<canvas name="myCanvas" width="250" height="300" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
기본 64로 변환하고 저장할 수 있습니까? 감사합니다 –
@ NguyễnThànhNam 로컬 저장소에 5MB 이상을 안정적으로 저장할 수없고 기본 64 문자열은 원시 PNG 파일의 4/3 크기이므로 최대 파일 크기는 3.75MB. 여전히 그렇게하고 싶으십니까? –
네, 단지 1 바코드 이미지를 저장하기 때문에 @Patric Roberts –