通过url在画布上打开图像

时间:2015-06-20 16:46:42

标签: javascript html5 url canvas

我一直在尝试使用网址在画布上打开图片。也许我没有把握好的东西,我所做的是:

<script>
     function Draw_url_to_canvas(url1,name_of_canvas){
         var myCanvas = document.getElementById(name_of_canvas);
         var img3 = new Image;
         var ctx2 = myCanvas.getContext('2d');
         img3.onload = function(){
             ctx2.drawImage(img3,0,0); // Or at whatever offset you like
         }
         console.log(url1);
         img3.src = url1;
     }
</script>
<input type="text" name="url-pass" id = "url-pass"></input>
<button type="button" onclick = "Draw_url_to_canvas(document.getElementById('url-pass').value,'drawCanvas')">Pass url-photo to canvas</button>

我正在尝试使用这个weburl:https://drive.google.com/file/d/0B8Fw3rEXlvPTZnBINU5odWdXSUU/view?usp=sharing我认为这对于这项工作是有效的,尽管到现在为止还没有工作。有什么想法吗?

0 个答案:

没有答案