2d coords to 1d coords
I am having troubles of trying to create a formula that takes 2-d coords and turn them into 1-d array coords. I know for simple one it would be
i = x +(y * arraywidth)
but I need one that will get the alpha value out of a texture. So when I go 0 , 0 it will give me index 3,the byte in which the first alpha value is in. Then when I get 1,0 it would give me 7. Do you get what I mean. I can't seem to get one made. The closest I got was working for the first row of y's but then when I go to the next row like 0,1 it won't work. Can someone please help me out with this math?
Thanks,
vbuser
i = ( x +(y * arraywidth) ) * 4
data = red<br>data[ i+1 ] = green<br>data[ i+2 ] = blue<br>data[ i+3 ] = alpha<br>
data = red<br>data[ i+1 ] = green<br>data[ i+2 ] = blue<br>data[ i+3 ] = alpha<br>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement