Quote: "Images
Optimizing images is mostly about saving memory as raw image data can take up a lot of space. A single 1024x1024 image uses 4MB (1024*1024*4), whilst a 2048x2048 image uses 16MB (2048*2048*4) and with mobile devices usually sharing video memory with RAM a device can quickly run out and close your app without warning. This is different from the image format used to save an image like PNG or JPG since the GPU loads it into an uncompressed format that takes up more space.
Use the smallest image resolution necessary
Since AppGameKit version 2.0.20 images no longer need to be a power of 2 in size, this means you are no longer limtied to sizes such as 1024x512, so if your image only needs 900x460 pixels then use an image size of 900x460 as that will help save memory. There are two exceptions to this, if you want to use UV offset or scaling to repeat the image multiple times, or if you want to use mipmapping, then the image must be a power of two in size. If you can get away with the quality reduction, you can also use a low quality image like 500x250 and display it using a sprite at a larger size using SetSpriteSize(SpriteID, 960, 460) as this improves loading times and reduces memory usage.
Keep as few images loaded as necessary
You should try to load images only when necessary, and delete them when you no longer need them. This is because images are one of the biggest consumers of memory (along with 3D objects), so keeping as few in memory as possible will prevent your app from crashing because the device ran out of memory. A rough guide is to have no more than about 250MB of image data loaded at any one time, but this will vary depending on the devices you are targetting. Higher end devices will be able to keep more in memory without crashing. To calculate how much memory an image will use when loaded into memory, multiply its width by its height and multiply by 4, for example a 500x500 image would consume 500*500*4 = 1,000,000 bytes, or 1MB
Use atlas textures
An atlas texture is an image that contains multiple textures on it which means a single image can be shared with multiple sprites to improve performance. Sprites that share the same atlas texture can be drawn at the same time which is faster than drawing sprites one at a time. One disadvantage to using atlas textures is that you cannot do UV scrolling with the textures it contains as modifying the UV will reveal the other textures sharing the image space. To load images from an atlas texture use LoadImage to load the atlas texture and then LoadSubImage to load images from it. You may use these sub images just like you would any other image. It is generally a good idea to leave 1 or 2 pixels of space between each image on an atlas texture to avoid them bleeding into each other during sampling. If you are using atlas textures with mipmapping turned on then you may need to increase this spacing further depending on how the image is used.
Do not use images greater than 2048 in size
Whilst some devices do support images greater than 2048, for maximum compatibility it is highly recommended that you do not exceed 2048x2048 for a single image. If you do end up using larger images and the device trying to load them does not support that size then AppGameKit will scale the image down to the maximum supported size and continue loading as normal, however this may increase loading times.
"
I'd say 2048 max
Atlas for images shared
Unique sizes for unshared
Quote: "or am I sounding like Ali G when he asked the computer expert if there would ever be a computer that could add 999,999,999,999 to 999,999,999,999? "
Da West Staines Massif
I ran into problems when displaying large prime numbers because more than X digits (depending on the math processor) got displayed with that 'E' crap.
So, I wrote a little program in DB Classic that enabled me to work with Mersenne primes where I could display numbers in the tens of thousands of digits long. (or longer if I wanted)
I was checking outputs so I need the whole number as it would look on paper, not that E crap, but I had to pause each page of numbers as they were displayed so I could read it.
That of course was dealing with multiplication, but that can be done with addition, so it was possible and easy enough to do.
(learnt dat at da Matthew Arnold Skool)
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1