Large images (1280x800) downscaled with new daily builds

I cannot correctly display images with one of its dimension larger than 1024 pixels. These images are automatically downscaled. This issue affects only new daily builds. I think that the last daily build which does not have this bug is 621.
I need to display full scale images on devices with 1280x800 resolution.
The images are automatically downscaled even if they are quite small - an image with 1280x10 will be also downscaled.
This does not work:
local a = display.newImage(“test.jpg”,0,0,true);

I think that it’s a bug and I reported it as a bug.
Any idea how to solve this? I need to use the new daily builds but also need to display images with one dimension larger than 1024 (1280x800 is a standard resolutions for many new Android tablets).

[import]uid: 7038 topic_id: 16128 reply_id: 316128[/import]

Correct, Corona for Android now automatically downscales images that are larger than 1024 pixels wide or high. We did this to work-around Android JVM memory limitations and max OpenGL texture size limitations. This is especially true of older Android devices that have a JVM 16 MB max memory limit per app. For example, loading a 2048x2048 image typically fails to load because it exceeds the 16 MB limit.

What we actually do is “down sample” the image as it is loaded, meaning that we read every other pixel while loading/decoding the image file. We have to do this when loading images from the Photo Library, Camera, or large images downloaded from the Internet… all of which we were never able to do on Android before without crashing the app.

That said, I agree that our image loader in Corona can still use some tuning. Particularly, if the image is too large to load, we should down sample it but also display a polygon size matching the size of the original image file. It should also be a bit smarter and not simply down sample based on a single dimension exceeding 1024 pixels.

For now, you can work-around this issue by setting the display object’s width and height to what you expect. This will stretch the image, but of course this also means that your image has lost quality due to the down sampling.

Another bit of advise, OpenGL requires images to have dimensions that are a power of 2. For example: 256, 512, 1024, etc. In Corona, if your image is not a power of 2, then we automatically increase the width or height to a power of 2 in order to meet OpenGL’s requirements. Now here is the problem. Your image is 1280 wide, which means Corona has to bump it up to 2048 pixels wide full of empty space. On top of that, we have to load the image as a raw uncrompressed bitmap. What this means is that your 1280x800 image wastes huge amounts of memory because it has to be loaded as a 2048x1024 32-bit per pixel bitmap, which calculates to 8,388,608 bytes… or just over 8 MB for 1 image! This is extremely wasteful and I highly recommend that you resize your large images to avoid this issue. Some people get around this by using 3rd party texture packers, which packs as many images as possible within a 1024x1024 image.

Anyways, that’s my 2 cents. Bottom line, the image loader in Corona does need some tuning, but you should also consider what I’ve said in the above paragraph. You can continue to build off of an older daily build, but I recommend that you try testing your app on an older device such as the original Droid to make sure it doesn’t crash due to memory limitations.
[import]uid: 32256 topic_id: 16128 reply_id: 59979[/import]

Joshua, thank you so much for your detailed answer. I understand your reasons but there should be a parameter to switch off this downscaling feature.
Our apps are not designed for old devices as for example the original Droid and I would really prefer better image quality on Galaxy Tab 10.1 over old devices compatibility. I tested our apps made with 621 build which 1280x800 bitmaps on many new devices without any problems.

BTW, 8 MB for one image, it’s quite relative. It was a huge amount of memory for personal computers 15 years ago. It looks like a huge amount of memory for some one or two year old mobile devices. But it’s quite OK for many new devices and probably, it will be a negligible amount in a year or two.

If I remember, Corona decided not to support Android 2.1 and older and I think that it was a correct decision. I decided not to support older Android devices so I really need higher resolution image support :slight_smile:
[import]uid: 7038 topic_id: 16128 reply_id: 59983[/import]

@Joshua,

I also understand your reasoning behind the change but I have to agree with Bohumil, we should have some kind of override option to this downscaling feature. Or it might be a bit smarter about that (if such thing is possible) and do it on older devices and/or based on the memory limit of the device.

@Bohumil,

Just thought a quick workaround for your problem. You may split your image into two parts 600x800 and load them in corona in full-res without downscaling and then stitch them in code…You may even put that in a function that overrides display.newImage.

That’s a bit more work overhead than doing it natively but at least you’ll have full-res image displayed… [import]uid: 10478 topic_id: 16128 reply_id: 60017[/import]

like PixelEnvision said, cut your images into more memory freindly chunks…

Joshua, one question about the images in corona: i read somewhere that Corona automatically reduce the size of images if the resolution is lower, so does it mean that if you do a game for Ipad at 1024x768, will the images be scaled down automatically when you see the app on iphone 3gs? (i’m using scale = “zoomEven”)
Or do you still need to make @2 images? [import]uid: 44010 topic_id: 16128 reply_id: 60036[/import]

Bohumil, PixelEnvision,

I understand your concerns. Especially if it was working for you before. I’m sure we can work something out. :slight_smile:

Just a bit of warning, the newest Android devices that I’ve tested on have a 24 MB JVM memory limit. That’s only 8 MB higher than older devices. So, it’s not a limitation of RAM, but more of a limitation imposed by the operating system and device. The app memory limit is rediculously low, so I think you can understand our frustration here. This makes loading 2048x2048 images, something iOS can do, impossible on Android without down sampling it.

That said, I just discovered the following AndroidManifest.xml setting today that I hope will work around this limitation…

android:largeHeap="true"

So, I haven’t given up yet!
r.pudlowski,

Corona will automatically scale down an image to fit the screen’s bounds unless you set the last argument of display.newImage() to true as Bohumil stated. Also, you can find a nice blog post about “Dynamic Image Resolution” here…
http://blog.anscamobile.com/2011/01/dynamic-image-resolution-made-easy/
[import]uid: 32256 topic_id: 16128 reply_id: 60057[/import]

so corona is dynamically resizing the image, so for example an image that is 512x512 on iphone4 will be scaled to 256x256 on 3G, using less video memory than the 512x512 one?
So what is the sense of using @2 images if corona will scale down them automatically (if you develop only for IOS)? [import]uid: 44010 topic_id: 16128 reply_id: 60064[/import]

On iOS, Corona will NOT downscale the image if it does not exceed the screen’s bounds. In which case, the @2 files are used for screen’s with a higher DPI so that you can show a more detailed image. That is, it shows a polygon of the same size, but with a higher resolution image. The blog post link I gave to you explains it better.

So, on iOS, it will only downscale the image if it exceeds the screen’s bounds (unless you tell it not to) or if it exceeds OpenGL’s max texture limit, which I think is 2048 pixels wide/high. [import]uid: 32256 topic_id: 16128 reply_id: 60065[/import]

hmmm… since i made my app at 1024x768, with zoom=“even”, can i use something like ["@1x"] = 0.5, so it will load the @1x images on lower screens?
Or must i rewrtite my game for 320x480?
ALso, is the redimension of sprite sheets with this method to be implemented in a future release of Corona? [import]uid: 44010 topic_id: 16128 reply_id: 60134[/import]

To support multiple resolution devices, you need to create images at the different resolutions to support the devices. This only works with display.newImageRect. [import]uid: 7559 topic_id: 16128 reply_id: 60230[/import]

Everyone,

This issue has now been fixed. The code was modified to support 2048x2048 images again without downscaling provided that the device supports that texture size. We’ve also bumped up the color quality of the image loaded into OpenGL from 16-bit to 32-bit, provided that the device has enough memory to load it with that image quality… otherwise it’s quality will be reduced to 16-bit. A reduce in color quality will likely only for large images exceeding 1024x1024 on older devices such as the original Droid. Newer devices such as the Samsung Galaxy S2 will always show images at full color quality and at their original size.

The above changes will be made available in the next daily build #641, which should be available to download tomorrow. [import]uid: 32256 topic_id: 16128 reply_id: 61741[/import]

Thank you, that was fast! Can’t wait to check it out… That sounds like the perfect solution for the problem… :slight_smile:

While talking Android, are you following the kindle (manifest settings) thread? [import]uid: 10478 topic_id: 16128 reply_id: 61747[/import]

Yes, I’ve seen the threads about Kindle Fire and Amazon submissions. I apologize for not adding my 2 cents to those threads, but we’re trying to figure it out for ourselves. We’re currently talking to Amazon now and testing out submitting an app for ourselves to identify what changes are needed to be made to Corona to make this work. Once we have definitive answers (Amazon’s FAQ is light on details) then we’ll offer a solution. I know many of you want to make the October 31st submission deadline and we’ll try to get something going before then. [import]uid: 32256 topic_id: 16128 reply_id: 61752[/import]

That’s great news, thx… :slight_smile:

Our first game is currently in review at amazon but I’m not sure if it’ll make it thru without those modifications…

My only chance would be supporting phone+tablets, so they might let the phone state read permission pass because of that… Anyway, I guess we’ll see that soon… [import]uid: 10478 topic_id: 16128 reply_id: 61756[/import]