I'm trying to write a function that takes an std::vector of game objects and saves them all as an image.
The game I'm making revolves around placing game objects in a specific way and I wanted users to be able to share different placements easily. Since there won't be much data, I decided that for every game object, each of it's applicable data members would be converted to a colour, and saved in the image as a pixel. To load game states my game would open the image and read each pixel from left to right, top to bottom and re-construct each game object.
The bit that I'm a little stuck on is how to convert a number to a colour, and back again. For example the x coordinate of a specific game object could be 42, I need a way to take 42, and convert it to 4 individual bytes (r,g,b,a).
I've realised that this, by itself, isn't that difficult. But I was wondering If I need to take the platform's integer size and endianness into consideration when I'm building this? And If so what would be a good way to deal with all that?