Image with size different than original

My app has portrait and landscape modes. In landscape, users will see a full 480×320 picture rendered. In portrait, they must see part of the “big picture”, in 320×480. I couldn’t find a way to use just one big image and position it accordingly (in portrait, for example, a 640x480 image occupies only part of the screen, instead of appearing full). Check this to see what I mean: (the background image size is 3264x2448): http://www.ppgplaces.com/test.png

At the end, my temporary solution was to use 2 images, one for each scenario. My main concern here is the total size of the application, as I am duplicating files. question is: is there a way to show a 640x480 (or any other size) full screen in portrait mode? Is this current behavior a bug?

Alex [import]uid: 4883 topic_id: 995 reply_id: 300995[/import]

Hi, Alex. The current behavior is a feature that automatically downscales images that are larger than the screen. Specifically, the latest versions of Corona will downscale to the next power-of-2 size larger than the native screen size. On iPhone, this currently means that anything over 512 x 512 will be downscaled on load.

The reasoning behind this is that texture memory is very limited on iPhone, and swapping data in and out of texture and main memory is very slow, so you don’t want to overrun the texture memory buffer if you can help it. Also, textures in OpenGL-ES are allocated in powers of 2, no matter what your image size is (so the sizes allocated are 128x512, 1024x1024, etc.)

However! There are definitely cases where you want to override our autoscaling, so we’ve got this filed as bug #28, and we plan to implement an optional flag to override this autoscaling behavior – so loading a 640 x 480 image on iPhone won’t be a problem once that flag is added.

The quick temporary solution is to either cut up the image, as you did, or just rescale it back up after loading, which will add a bit of blur but might look OK. The rescaling method will also save lots of texture memory, since a 640x480 image allocates twice as much texture memory as the downscaled 512x(?) image – so downscaling/upscaling might be a superior approach even after we add the new flag.

Note that the largest possible texture is 1024x1024 on iPhone 3G, and 2048x2048 on iPhone 3GS. There is no way to load a single image larger than that without chopping it up into tiles. (Looking at the iPhone photo viewer app, I think it may be downscaling photos to no more than 2048x2048, and then upscaling slightly in software, since the photos look a bit pixellated at full magnification.) [import]uid: 3007 topic_id: 995 reply_id: 2366[/import]