Home Game Development How can I convert a uncooked pixel buffer (1D array) right into a 2D array?

How can I convert a uncooked pixel buffer (1D array) right into a 2D array?

0
How can I convert a uncooked pixel buffer (1D array) right into a 2D array?

[ad_1]

I’ve to cope with a uncooked buffer representing some pixels, particularly the pixels crate. So far I’m able to do some magic from the examples, nonetheless it’s terribly dangerous in the case of readability and I want to convert that buffer right into a 2D array, with a view to entry it extra effectively and make it simpler for collision detection. So with a view to draw a single pixel in place (512, 423), I need to do that:

fn draw_something(&mut self) -> /* ... */ {
    self.pixel_array_but_2d[512][423] = /* Some shade in hex */;
}

I do know I may do that with different methods with out the conversion to a 2D array, however I nonetheless need to do with the best way I described.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here