Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am trying to make a game that will take a image and get its bytes into an array, such as a 3x3 img will return 9 bytes. I want to do this in Java Script so I can get the img. I really would appreciated it if you would help me. Thanks

What I have tried:

I have tried a lot of stuff on the internet and I couldn't find out how to use it :/
Posted
Updated 25-Apr-16 1:05am
Comments
Sergey Alexandrovich Kryukov 23-Apr-16 15:00pm    
I doubt it's possible with JavaScript. And no, 3x3 image is not 9 bytes. And 3x3 will be hardly visible.
All you are writing about makes no sense at all. Better tell us what do you want to achieve.
—SA

this doesn't work?
[^]

var img = new Image();
img.src = 'image.jpg';
var context = document.getElementById('canvas').getContext('2d');
context.drawImage(img, 0, 0);
data = context.getImageData(x, y, 1, 1).data;
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900