2012-11-23 5 views
1

IE (9 세 미만) 브라우저에서 캔버스 기능을 지원하기 위해 excanvas.js 라이브러리를 사용하고 있습니다. 현재 직면하고있는 문제는 excanvas가 drawImage() 메서드의 첫 번째 인수로 이미지를 기대한다는 것입니다. 다른 캔버스 나 비디오를 첫 번째 인수로 지원하지 않는다는 것을 알게되었습니다. 이 기능을 구현하기위한 해결 방법은 무엇입니까? 내 코드는 다음과 같습니다.excanvas를 사용하여 캔버스에 이미지 그리기

var canvas1 = document.getElementById("canvas1"); // Get the first canvas Element 
    var canvas2 = document.getElementById("canvas2"); // Get the second canvas element 
    if (typeof G_vmlCanvasManager != 'undefined') { 
     canvas1 = G_vmlCanvasManager.initElement(canvas1); // Initialise with excanvas 
     canvas2 = G_vmlCanvasManager.initElement(canvas2); 
    }  

    if (canvas1.getContext) { 
     var ctx1 = canvas1.getContext("2d"); 
     var ctx2 = canvas2.getContext("2d"); 
     var img = new Image(); 
     img.onload = function() { 
      ctx1.drawImage(this, 0, 0, 200, 200); // Draw the image on first canvas 
      ctx2.drawImage(canvas1, 0, 0, 200, 200); // Draw the image on to the second canvas using the first canvas 
     } 
     img.src = "image1.jpg";   
    } 

Ie8 이하의 브라우저에서는 작동하지 않습니다. 어떻게이 문제를 해결할 수 있습니까?

답변

0

나는 이런 식으로 뭔가 시도를하려는 :

function canvasToImage(canvas) { 
    var img = new Image(); 
    img.src = canvas.toDataURL(); 
    return img; 
} 
+1

canvas.toDataURL를(); 이전 IE 브라우저에서는 지원하지 않습니다 – KiranPalode

+0

ok : o ......... – EricG