微信 drawImage

[pcsh lang="js" tab_size="4" message="" hl_lines="" provider="manual"]

function getimgbase64(file){
	var canvas = document.createElement('canvas');
	var ctx = canvas.getContext('2d');
	canvas.width = canvaswidth;
	canvas.height = canvasheight;
	var x=$('#make-photo .theme').children('.photo').css('left').split('px')[0];
	var img = new Image();
	function tmpLoad() { 
		x = x > 0 ? x : -x;
		ctx.drawImage(img, x ,0,canvaswidth,canvasheight,0,0,canvaswidth,canvasheight);	//微信中,第四五个参数貌似不能超越画布大小,正常浏览器无此限制
		def.resolve(canvas.toDataURL('image/png'));
	}
	img.onload = tmpLoad;
	img.height = canvasheight;
	img.src = file; 
}

[/pcsh]

微信中drawImage函数貌似有bug

 

 

此处评论已关闭