Updating a Table in native code

I wrote a script called Collision Maps which takes an image, parses its pixels, and caches the results in a Table object, where each (x,y) has a one-to-one correspondence with each pixel on the image.


I do something silly like looping over every pixel and calling get_pixel, which is very slow for sufficiently large images.


I could probably avoid doing this by simply accessing the pixel when I need it, but I figured I might as well figure out how to update a Table using pointers and stuff cause I would like to use images for a variety of things to enhance mapping functionality.


How would I do this?


The approach I'm thinking is to first create a table in Ruby, then pass a pointer to that table to some dll function, which will then update the values by offsetting the pointer and writing a new value. Then when the function is done, I should see that my table has been updated.


However I don't know how the table is stored in memory.


Has anyone worked with Table objects?
Only in accessing them like multidimensional arrays.


So for a map of 10x10, is your table also 10x10 (one pixel per map tile) or is it 320x320? If a tile is either passable or impassable, would it save time and memory by having each address in a table refer to a single map tile rather than a single pixel? It would be harder to draw, but you could let them still draw each tile 32x32 and just take the middle pixel of each tile into your table.


I know it's not what you asked, but the question came to me when I saw your script and I was going to ask you about it then. This just reminded me.
The table is 320x320 but I take into consideration tile size and only take the top-left corner of each tile. I guess it wouldn't really matter which pixel I grab from within a tile.

Original thread: https://forums.rpgmakerweb.com/threads/updating-a-table-in-native-code.17834/