Current location: Hot Scripts Forums » General Web Coding » HTML5 » getImageData and putImageData


getImageData and putImageData

Reply
  #1 (permalink)  
Old 07-10-11, 09:14 AM
snap1985 snap1985 is offline
New Member
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
getImageData and putImageData

Hello,
im pretty new to the whole html5-thing and I dont have any experience regarding JavaScript. Which is probably the reason why this wont work. I simply want to copy a part of a picture somewhere else in the canvas, but something seems to be wrong with my code.
I would really appreciate it if someone could take a look at my sourcecode.


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function draw() {
var ctx = document.getElementById('cvs').getContext('2d');
var img = new Image();
img.src = 'futurama.png';

img.onload = function(){
ctx.drawImage(img,0,0);
}

var imgData = ctx.getImageData(50, 50, 80, 80);
ctx.putImageData(imgData, 400, 600);
}
</script>
</head>
<body onload="draw();">
<canvas id="cvs" width="600" height="1000">
</canvas>
</body>
</html>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:31 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.