Spritesheet can't handle single row sheets > 640 pixels wide

Unfortunately I think I’ve found another problem with spritesheets. If, for example, you wish to have a spritesheet 1 frame high and n frames across, you’ll get assertions if the source image file is > 630 width. This may be related to bug 1808 I reported.

The assertion spuriously reports that frames don’t fit in sheet. The first error is for the height, even though this hasn’t changed. If you subtract 1 from this it gets through but still fails on the width test. For example, it reports an error for an image height of 40 pixels with a frame height of 40 when the image width is > 640. If you subtract 1 it’s OK. So it seems that Corona is shrinking the image dimensions internally.

The test code I’ve supplied shows this. Files 320x40 and 640x40 are OK but 960x40 and 1040x40 are not.

Project file here
[import]uid: 3953 topic_id: 1845 reply_id: 301845[/import]

This bug is still in the new beta game SDK. I guess it’s not considered important, but it may come back to bite sometime, as it suggests there’s some parsing error in the image load code. [import]uid: 3953 topic_id: 1845 reply_id: 5575[/import]

In your project, the file 24x1.png is actually 640 wide, not 960. Updating it to 960 (by cropping the 1040 version) works.

In Corona right now 1024 is the max texture size, so the 1040 version doesn’t work. 1024 is the limit on iPhone 2G and 3G. Newer devices support larger textures, and I’ve added a case to ask the device for the max texture size. However, for compatibility we recommend staying with 1024. [import]uid: 54 topic_id: 1845 reply_id: 6469[/import]

Thanks for your response, Eric. You are right of course. 1040 was a mistake. Was meant to be 1024. And the other reported assertion was, in fact, correct because one of the loads did not result in integer frame sizes. This leads back to bug report 1808 as stated in the original post:

Running this script:

local img = display.newImage(iName) print("Image " .. iName .. " width: " .. img.width .. ", height: " .. img.height)end[/code]Gives this output (I made sure the file sizes were correct this time):Image 320x40.png width: 320, height: 40Image 640x40.png width: 512, height: 32Image 960x40.png width: 512, height: 21Image 1024x40.png width: 512, height: 20For building Lua libraries and utils for Corona, it would be real handy to check image file dimensions without having to manually parse them. [import]uid: 3953 topic_id: 1845 reply_id: 6497[/import]

If you don’t want images to autoscale to the display, use the isFullResolution flag.

Sprite sheets are not handled in the same way as images. Autoscaling is always off. There is a max size enforced, which is currently 1024. This isn’t accurate for some devices and I opened a case to handle this (especially on iPad). However for compatibility, you should stick with 1024. [import]uid: 54 topic_id: 1845 reply_id: 6683[/import]

I’m not sure why, for example, an image 640x40 would “autoscale” to 512x32. Is this a quirk of the simulator, in that it thinks the iPhone sim display is 512 wide? [import]uid: 3953 topic_id: 1845 reply_id: 6689[/import]