akorukmez Posted July 29, 2013 Share Posted July 29, 2013 İmage mapping or pixel mapping is it possible html5?examplehttp://www.youtube.com/watch?v=iAdnFhNS110http://www.youtube.com/watch?v=AIue5O7K59Y&list=ELp5mgUw5g9EY Quote Link to comment Share on other sites More sharing options...
OadT Posted July 29, 2013 Share Posted July 29, 2013 You can paint your image on a canvas and use getImageData to get the single pixels, for examle:var can = document.getElementById("canvas");var con = can.getContext("2d");con.drawImage("map.png", 0, 0);var data = con.getImageData(0, 0, 20, 20);r = data.data[0];//value of red in first pixel (between 0 and 255)g = data.data[1];//value of green in first pixelb = data.data[2];//value of blue in first pixelalpha = data.data[3];//transparent of first pixelso with a for-loop you can read all pixels of your map and convert them to an object in your world or whatever you want akorukmez 1 Quote Link to comment Share on other sites More sharing options...
akorukmez Posted July 29, 2013 Author Share Posted July 29, 2013 You can paint your image on a canvas and use getImageData to get the single pixels, for examle:var can = document.getElementById("canvas");var con = can.getContext("2d");con.drawImage("map.png", 0, 0);var data = con.getImageData(0, 0, 20, 20);r = data.data[0];//value of red in first pixel (between 0 and 255)g = data.data[1];//value of green in first pixelb = data.data[2];//value of blue in first pixelalpha = data.data[3];//transparent of first pixelso with a for-loop you can read all pixels of your map and convert them to an object in your world or whatever you want Thank you very much.ı'm thankful Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.