Rbx-image-table | turn any bitmap into a table!


rbx-image-table

A simple utility for converting any image into a Lua 2D array, designed for Roblox.
VERY BODGED TOGETHER!

An example table would be like the following

return {
	[1] = {
		[1] = Color3.new(0.25, 0.5, 1),
		[2] = Color3.new(0.25, 0.5, 1),
		...
	}
	...
}

Where the first array corresponds to the x-axis of the image, and the next nested array corresponds to the y-axis of the image

My motivation behind this was to be able to cache bitmaps into Roblox, as a performance optimisation technique (as it means the CPU will not die trying to decode a PNG buffer using MaximumADHDs PNG library). If we can cache large 16k level images (such as the textures I’m using for my game), it means we don’t have to repeatedly request a domain for a PNG buffer, which is great when you are working for mobile!

usage

  • compile the project
  • execute the binary and select an image
  • wait
  • file will save to a path of your choosing

OR:

  • navigate to the releases page and download a prebuilt binary

attributions:

SLPP - GitHub - SirAnthony/slpp: Simple lua-python parser


3 Likes

I have used something similar to upload videos into Roblox. Good job on this resource!

However, I ran into problems with optimization and size with the same method you are using, to fix this, I turned the colors to tables with the color value and how many times it has repeated

Instead of doing:

[1] = Color.new(1.0, 1.0, 1.0),
[2] = Color.new(1.0, 1.0, 1.0),
[3] = Color.new(1.0, 1.0, 1.0)

I did this:

[1] = {Color.new(1.0, 1.0, 1.0),3},
...

You can also remove the 1 .0 part of the value and certain spaces. Doing these will improve the size by a lot.

Since I have done videos, I separated them into frames instead of individual pixels.
This is how it looked: (This code has been optimized for Bad Apple, which is black and white, so the color value was only the shade.)

2 Likes

yeah a lot of stuff like decimal precision is just an after-effect of python unfortunately, the tool itself is quick and dirty so i didn’t really see a need to optimise it in this way (it is being used for a hack project right now).

if anyone wants to make quality of life changes or improvements please send a pr to the repository!

that’s a nice technique but i would have to create a lookup module for interpreting this kind of data which i think is out of the scope of the tool itself, definitely something worth looking into though

1 Like