Get actual device screen size in letterbox mode?

Hi sorry if this is a noob question, but I read in the docs that letterbox may return the wrong size, and in my tests it does. So I was wondering if it’s possible to get the exact device screen size in physical pixels in letterbox mode?

For example I am on iPhone 3G 320x240. My content is an irregular size like 640x852. My content alignment is top-center. How would I calculate the device screen size back to 320x240?

Thanks! [import]uid: 99244 topic_id: 20317 reply_id: 320317[/import]

*Polite bump* [import]uid: 99244 topic_id: 20317 reply_id: 79624[/import]

Hey there,

Unfortunately I don’t have an easy answer, however this thread should be of use to you I hope; http://developer.anscamobile.com/forum/2012/01/01/differentiating-between-small-or-large-screen-similar-screen-resolution

Or is your question more specific than that? If your concern is the size of iOS devices only then you can get the model and set _W and _H variables accordingly.

Peach :slight_smile: [import]uid: 52491 topic_id: 20317 reply_id: 79665[/import]

There is not such thing as a polite bump :wink:

Now, onto what matters:

realDeviceWidthPixels = (display.contentWidth - (display.screenOriginX \* 2)) / display.contentScaleX

substitute X with Y and Width with Height and you got the device height in pixels. This works for every device out there and I think even for every scaling type, although I only tested with letterbox. [import]uid: 61899 topic_id: 20317 reply_id: 83521[/import]

Looks like CluelessIdeas is not so clueless, this was exactly what I needed. One thing I would say is that you may need to use math.round on the resulting figure. For my iPhone 3gs the width came to 479.99998092651 which is just about right, but obviously not close enough for if realDeviceWidthPixels == 480 then... [import]uid: 84115 topic_id: 20317 reply_id: 119881[/import]

Looks like CluelessIdeas is not so clueless, this was exactly what I needed. One thing I would say is that you may need to use math.round on the resulting figure. For my iPhone 3gs the width came to 479.99998092651 which is just about right, but obviously not close enough for if realDeviceWidthPixels == 480 then... [import]uid: 84115 topic_id: 20317 reply_id: 119881[/import]