添加徽标添加图片,下载必须下载,但不起作用 (你可以尝试浏览器)
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
function Up() { //upload
var ctx = document.getElementById('canvas').getContext('2d'),
img = new Image(),
src = "http://chu93.aphp.fr/wp-content/blogs.dir/32/files/2015/10/LOGO-YOUTUBE.png";
img.src = src;
img.onload = function() {
ctx.drawImage(img, 0, 0, 480, 400);
}
}
function download() { //download
var dt = canvas.toDataURL('image/jpeg');
this.href = dt;
};
downloadLnk.addEventListener('click', download, false);
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body onload="doCanvas()">
<button type="button" onclick="Up()">Add logo</button>
<a id="downloadLnk" download="img.jpg">Download</a>
<canvas id="canvas" width="480" height="400"></canvas>
<script src="config.js"></script>