Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iPad中的Bug';什么是html5画布drawimage()实现?_Iphone_Ipad_Safari_Html_Canvas - Fatal编程技术网

Iphone iPad中的Bug';什么是html5画布drawimage()实现?

Iphone iPad中的Bug';什么是html5画布drawimage()实现?,iphone,ipad,safari,html,canvas,Iphone,Ipad,Safari,Html,Canvas,经过一些艰苦的调试,我想我在iPadSafari的canvas.drawImage()实现中发现了一个bug。具体来说,这种过载: 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似乎有时会忘记对图像进行切片,

经过一些艰苦的调试,我想我在iPadSafari的
canvas.drawImage()
实现中发现了一个bug。具体来说,这种过载:

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>

draw=函数(){
var ctx=document.getElementById('cc').getContext('2d');
var timg=新图像()
timg.onload=函数(){
ctx.fillStyle='rgb(100100)';
ctx.fillRect(0,0256256);
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";
};
您可以运行它,也可以查看iPad的输出

这个bug似乎不存在于任何其他浏览器上,包括桌面Safari。如果你在iPad上刷新页面,它似乎也会消失

我的
drawImage()
有什么问题吗


有人能找出为什么会发生这种情况吗?如果有特定的值,我可以简单地避免,这样它就不会发生了。。。或者其他解决方法?

这个错误似乎已经在iOS 4.2中修复。至少,我看不到这种情况再次发生。

如果您认为在任何软件中发现了错误,请向开发人员报告(本例中为苹果:)。得到报告的bug是得到修复的bug。