Memory Management Pt 2 - The same with less.

Its 320x160, so to get the iPad to display this I need to visit its canvas store and buy some canvas, now as we all know from the first post, canvas most be in powers of 2. So the smallest canvas the ipad has that holds my master piece is 512x256 which looks like this.

Which is a waste. Look at all the black that can’t be used for anything else.... Canvas is very limited at the iPad’s canvas store.
The smart painter will see that you can put canvas pieces next to each other and paint on each part. So if I get a 256x128 and a 64x128 and 256x32 and a 64x32 can then fit the picture on perfectly and save all the wasted space like so.

Now while mine fits perfectly, even if it didn’t it would really reduce the wasted space.
What does this mean in RAM terms.
512x256 = 512KB
VS
256x128 = 128KB
64x128 = 32KB
256x32 = 32KB
64x32 = 8KB
Total = 200KB
Less than half the RAM same image, looks no different.

Now you can’t do this is you want to rotate the image or put it on physics because currently we don’t have a system to bolt these together. But if you want to move the objects around on behaviours then you just move all the pieces and nobody will ever know.
Odd shapes gives you even better saving for example these flags, that nicely fit in a 512x512

The Background page
Each page has a background image, its plain white, it is a fullscreen texture and uses 4MB, now if you use or don’t use it, it is 4MB, SO USE IT, fill it with as much stuff as you can. If it doesn’t move, rotate, scale and nothing needs to slide behind it, put it in the background image. Everything you put into the texture for the back of the page is FREE.

If you want to make something happen when you press an item , like play a sound, that doesn’t not cause the item to move. Then put the item in the background texture. Then make a 8x8 texture that is fully transparent/alpha and use the Frame to make it as big as you need. This way you get the same behaviour for 256 Bytes! And you can use that same texture everywhere in the book and size it to what you need it to be, nobody will notice it being stretched as you can’t see any of it.