2010-05-20 109 views
0

经过一番艰苦的调试之后,我想我在iPad Safari的canvas.drawImage()实现中发现了一个错误。具体地,本超载:iPad的html5 canvas drawimage()实现中的错误?

void drawImage(in HTMLImageElement image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh); 

当切片的图像和缩放下来,似乎Safari浏览器有时忘记切片图像并简单地缩放整个图像下移。这发生在一个随机的基础上,但我已经能够在清除safari缓存后一直在iPad上重现它。下面是代码:

<script> 
draw = function() { 
    var ctx = document.getElementById('cc').getContext('2d'); 
    var timg = new Image() 
    timg.onload = function() { 
    ctx.fillStyle = 'rgb(100,100,100)'; 
    ctx.fillRect(0,0,256,256); 
    ctx.drawImage(timg, 0,0, 128, 128, 0, 0, 63,63);     
    ctx.drawImage(timg, 0,0, 128, 128, 128, 0, 65,65);    
    }; 
    timg.src = "http://amirshimoni.com/ipadbug1/1234.jpg"; 
}; 
</script> 
<body onload="draw();"> 
<canvas id="cc" width="256" height="128"></canvas> 
</body> 

你可以运行它here或看到从iPad here输出。

此错误似乎并不存在于任何其他浏览器上,包括桌面Safari。如果您刷新iPad上的页面,它似乎也会消失。

我做错了drawImage()

任何人都可以找出为什么会发生这种情况,如果有特定的值,我可以避免,所以它不会发生......或其他解决方法?

+1

如果您认为您在任何软件中发现错误,请将其报告给开发人员(Apple,在这种情况下为:http://developer.apple.com/bugreporter/)。获得报告的错误是修复的错误。 – 2010-05-20 23:45:15

+0

谢谢,我提交了。 – Amir 2010-05-21 00:14:16

回答

1

此错误似乎已在iOS 4.2中修复。至少,我没有看到它再发生。