Image size lager than 2048

Hello,

I developed an app on windows/android, everything is fine.

But when I tried to build for iOS, I found a big problem.

There is a big png file (2112*1344) that I use for drag-able background.

I just created it by:

local bg = display.newImage(“res/bg.png”, x, y)

It behaves correctly on windows simulator and all android devices I have.

However, the image on mac simulator/iOS device is different.

The image size is not really 2112*1344, it will be scale (down), the scale factor varies with device.

Thus I can’t get a correct full background.

I don’t get it, why is this happening on mac?

Is it the size that lager than 2048 causes this problem?

If I use imageSheet to deal with it, will it be different? (unfortunately I don’t have a mac to test now)

And if the background is combined from the imageSheet, will it save some memory for me?

Thanks for reading/reply.

Hi hydralisk_mk2

You can use local bg = display.newImageRect(“res/bg.png”, imageWidth, imageHeight)

Also please post how you are scaling the image.

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks for reply. :slight_smile:

Part of my config:

    content = {
        width = 540,
        height = 960,
        scale = “letterbox”,
        fps = 30,

     },

I didn’t scale the background, I just created it (1:1).

I did try display.newImageRect (unfortunately…) on windows/android only,

they work fine, both newImage and newImageRect are able to show 2112*1344 image in full size on PC/android.

since I did not force isFullResolution = true.

But on mac, the image size is weird even on simulator. (I can’t try newImageRect() on mac now :<)

(I don’t really have a mac. I test it only when I can.) :confused:

So I add a newRect with exactly the same size, location, set transparent for test.

The image is always smaller then the newRect.

But on windows/android, the background image and the newRect are perfectly matched.

If anything else, I did insert the background into a map group, but I didn’t scale anything.

Why does corona act different with single image?

Hi hydralisk_mk2

Try it

local bg = display.newImageRect(“res/bg.png”,2112,1344)

bg.x = display.contentWidth*0.5

bg.y = display.contentHeight*0.5

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks, newImageRect does work.

But what I don’t understand is why does mac/iOS behaves differently with newImage?

And seems to happen with large images only.

newImage force scale already, doesn’t it?

Why does it show smaller size?

Hi @hydralisk_mk2,

Ultimately, newImageRect() should be used in favor of newImage(), specifically because it handles dynamic asset selection. This is incredibly important in developing for multiple devices. I recommend that you use this unless there’s some specific reason why you can’t.

Take care,

Brent

I got it!

I will replace all newImage() with newImage() for all my projects.

But this should be included in the guide imho. :smiley:

Hi hydralisk_mk2

You can use local bg = display.newImageRect(“res/bg.png”, imageWidth, imageHeight)

Also please post how you are scaling the image.

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks for reply. :slight_smile:

Part of my config:

    content = {
        width = 540,
        height = 960,
        scale = “letterbox”,
        fps = 30,

     },

I didn’t scale the background, I just created it (1:1).

I did try display.newImageRect (unfortunately…) on windows/android only,

they work fine, both newImage and newImageRect are able to show 2112*1344 image in full size on PC/android.

since I did not force isFullResolution = true.

But on mac, the image size is weird even on simulator. (I can’t try newImageRect() on mac now :<)

(I don’t really have a mac. I test it only when I can.) :confused:

So I add a newRect with exactly the same size, location, set transparent for test.

The image is always smaller then the newRect.

But on windows/android, the background image and the newRect are perfectly matched.

If anything else, I did insert the background into a map group, but I didn’t scale anything.

Why does corona act different with single image?

Hi hydralisk_mk2

Try it

local bg = display.newImageRect(“res/bg.png”,2112,1344)

bg.x = display.contentWidth*0.5

bg.y = display.contentHeight*0.5

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks, newImageRect does work.

But what I don’t understand is why does mac/iOS behaves differently with newImage?

And seems to happen with large images only.

newImage force scale already, doesn’t it?

Why does it show smaller size?

Hi @hydralisk_mk2,

Ultimately, newImageRect() should be used in favor of newImage(), specifically because it handles dynamic asset selection. This is incredibly important in developing for multiple devices. I recommend that you use this unless there’s some specific reason why you can’t.

Take care,

Brent

I got it!

I will replace all newImage() with newImage() for all my projects.

But this should be included in the guide imho. :smiley: