Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

display.pixelWidth/Height of iPhone 4 doesn't show images at full display.contentWidth/Height
Started by ranflas Jun 20 2016 02:37 PM

2 replies to this topic
ios display contentwidth pixelwidth iphone 4 newimage display.newimage
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Enthusiast

  • 74 posts
  • Corona SDK

Each iOS device (iPhone 4, 5, 6, 6, Plus) has its own display.pixelWidth and display.pixelHeight


In config.lua, I have:

application = {
   content = {

      width = 750,
      height = 1334,


Any image that is full screen which I am using in the app is 750 x 1334.


When I add it onto the screen using:

display.newImage(nameOfGroup, "ImageName.png",375,667)

The image fills the screen on every device but the iPhone 4.

On the iPhone 4 (both simulator and device), the image is significantly smaller than the size of the screen and centered.


Can anybody account for why this happens or how I may be able to get around it other than creating assets at 640 x 960 and using those with a conditional:

if (display.pixelHeight == 960) then
    display.newImage(nameOfGroup, "ImageNamePhone4.png",320,480)
    display.newImage(nameOfGroup, "ImageName.png",375,667)

Thanks so much in advance!

[TOPIC: post.html]

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

First of all, display.newImage(), the 2nd and 3rd parameters are the X and Y to center the image on. I believe you want to use display.newImageRect() where the 2nd and 3rd parameters are the width and height of the image.


Focus on your defined content area and understand that on the iPhone 4, since you're using images shaped for the 16:9 shaped iPhones, part of it will get cut off.



[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 14 posts
  • Corona SDK

I was using a display.newRect() and the same problem was happening.


This change for display.newImageRect() solved my doubt.


Thanks Rob!