This is question has been really killing me. In XNA when you want to convert an image to color data using Texture.GetData, it only lets you make it a one dimensional array instead of a 2D one. This makes it much more difficult to work with. Is there a specific reason it's like that?
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
|
Xna is built uppon Directx and Directx use this strategy cause this is how the the display driver exposes information it gets from the video board. (actually it exposes an array of bytes). Also to give you a 2d array, the api would need to know the "size" of each texel and the dimensions of you texture to make the conversion. For performance reason, they let the user decide if they want/need to make the conversion. You can always convert the recovered array in a 2d one. (or you can wrap it in a class that make the coordinate conversion) |
||||
|
|
As Tpastor had a great answer on why, here is how to convert it from the hard to read 1D array, to a simple 2D array for easy access to each pixel.
|
|||||||
|