[code]
/**
* ...canvas 加载图片
* @author amyflash.com
*/
(function() {
var ctx = document.getElementById("canvas").getContext("2d");
var img=new Image();
img.src = "rusty.jpg";
img.onload = function()
{
var x=30;
var y=0;
var img_width =100;
var img_height = 100;
//ctx.drawImage(this,x,y); //按原图大小显示
//ctx.drawImage(this,x,y,img_width,img_height);//按指定宽高显示
ctx.drawImage(this,x,y,img_width,img_height,x,y,150,150);//截取150*150显示
};
})();
[/code]