Display.save text missing on high res devices

Trying to save a 512x256 image out with some text over the top.  Reproducible on ios device and simulator.

I create a group, with an image and some text centered.  I save that group using display.save and on the iPhone it works fine, and on iPad air (1536x2048) the text does not get saved.

Saved image on iPhone 4/5/6

Saved image on iPadAir

The group however looks fine on the device/simulator screen, you can see where the text /should/ be.

This is using font “Walibi” but I have even tried native.systemFontBold and the same thing happens.

[lua]

    local group = display.newGroup()

    local snapshot = display.newImage(“assets/twitter_bg01.png”)

    – scale would be virtual width / actual width of device

    snapshot.width = 512 * (display.contentScaleX)

    snapshot.height = 256 * (display.contentScaleY)

    snapshot.x = 0

    snapshot.y = 0

    snapshot.anchorX = 0

    snapshot.anchorY = 0

    group:insert(snapshot)

    local fontSize = 36 * display.contentScaleX

    local tx = 256 * display.contentScaleX

    local ty = 24 * display.contentScaleY

    local shadowText = display.newText( group, theText, tx + 5, ty + 10, native.systemFontBold, fontSize )

    shadowText:setFillColor(0,0,0,0.3)

    group:insert(shadowText)

    local levelText = display.newText( group, theText, tx, ty, native.systemFontBold, fontSize )–Walibi0615

    levelText:setFillColor(255/255, 162/255, 39/255, 1)

    group.anchorX = 0

    group.anchorY = 0

    group.width = 512 * (display.contentScaleX)

    group.height = 256 * (display.contentScaleY)

   

    display.save(group, {filename=“twitter.png”, isFullResolution=true, baseDir=system.DocumentsDirectory})

[/lua]

Any ideas? I’m using Corona Build: Version 2014.2511 (2014.11.18) (Looks like an old version but it is the latest up to date public release).

Edit: I just tried it in the latest daily build Version 2015.2644 (2015.5.21) and the problem is still there.

Hi @BearHugGames,

Remember that groups don’t obey anchors unless you use the “.anchorChildren” property, but that carries some other caveats with it. Also, you shouldn’t try to manually resize the group by setting its width and height. Both of these factors are probably contributing to your issue.

What I expect you’re trying to do is reduce (shrink) the group size before saving it. If so, consider scaling the group (and not using anchor points of 0,0), then use display.save() on the group.

Best regards,

Brent

Hi Brent thanks for the advice. Yes there’s a lot of fiddling in that code to get the image to render out at 512x256 exactly.

However, I’ve cleaned it up completely so this is the new code and the issue is still there.

[lua]

local group = display.newGroup()

local snapshot = display.newImage(“assets/twitter_bg01.png”)

group:insert(snapshot)

local levelText = display.newText( group, “TESTING”, 0,0, native.systemFontBold, 32 )

display.save(group, {filename=“fonttest.png”, isFullResolution=true, baseDir=system.DocumentsDirectory})

[/lua]

It seems related to the settings in config.lua - various width/height ratios will make it work or not.

Running as iPad Air (1536x2048)

768x1024 works

768x1136 does not work

640x960 does not work

[lua]

application = 

{

    content =

    {

        fps = 30,

        width = 640,

        height = 960,

        scale = “zoomEven”,

        xAlign = “center”,

        yAlign = “center”,

    },
}

[/lua]

Doesn’t 0,0 put the font half off the screen in all cases? What if you center it in the content area?

It is actually centered in the content area, I ditched all the anchor stuff from before.

This is what the above code generates when width and height in config.lua are set to various values…

I tried various height values for the screen in the config, and this is where it stopped working.

768x1063 works perfectly, text is centered (It’s there, sorry the text is white and hard to see in the thumbnail)

768x1064 does not show text at all

Seems to be something to do with the width and height ratios. It either works perfectly (it’s in the center as expected) or it’s not there at all.

Incidentally I seem to be able to make the background or other objects disappear depending on the ratio of width:height in the config, despite the group always rendering fine in the game scene.

Okay, found the bug/work around.

Turns out if you are using display.save to save a group, that group and all it’s contents need to be inside the devices bounds too (even if all sub images/texts are within the bounds of the group being saved).

Changing the group x/y positions means it appears when it gets saved.

group.x = 512

group.y = 512

display.save(group, {filename=“twitter.png”, isFullResolution=true, baseDir=system.DocumentsDirectory})

Hi @BearHugGames,

Remember that groups don’t obey anchors unless you use the “.anchorChildren” property, but that carries some other caveats with it. Also, you shouldn’t try to manually resize the group by setting its width and height. Both of these factors are probably contributing to your issue.

What I expect you’re trying to do is reduce (shrink) the group size before saving it. If so, consider scaling the group (and not using anchor points of 0,0), then use display.save() on the group.

Best regards,

Brent

Hi Brent thanks for the advice. Yes there’s a lot of fiddling in that code to get the image to render out at 512x256 exactly.

However, I’ve cleaned it up completely so this is the new code and the issue is still there.

[lua]

local group = display.newGroup()

local snapshot = display.newImage(“assets/twitter_bg01.png”)

group:insert(snapshot)

local levelText = display.newText( group, “TESTING”, 0,0, native.systemFontBold, 32 )

display.save(group, {filename=“fonttest.png”, isFullResolution=true, baseDir=system.DocumentsDirectory})

[/lua]

It seems related to the settings in config.lua - various width/height ratios will make it work or not.

Running as iPad Air (1536x2048)

768x1024 works

768x1136 does not work

640x960 does not work

[lua]

application = 

{

    content =

    {

        fps = 30,

        width = 640,

        height = 960,

        scale = “zoomEven”,

        xAlign = “center”,

        yAlign = “center”,

    },
}

[/lua]

Doesn’t 0,0 put the font half off the screen in all cases? What if you center it in the content area?

It is actually centered in the content area, I ditched all the anchor stuff from before.

This is what the above code generates when width and height in config.lua are set to various values…

I tried various height values for the screen in the config, and this is where it stopped working.

768x1063 works perfectly, text is centered (It’s there, sorry the text is white and hard to see in the thumbnail)

768x1064 does not show text at all

Seems to be something to do with the width and height ratios. It either works perfectly (it’s in the center as expected) or it’s not there at all.

Incidentally I seem to be able to make the background or other objects disappear depending on the ratio of width:height in the config, despite the group always rendering fine in the game scene.

Okay, found the bug/work around.

Turns out if you are using display.save to save a group, that group and all it’s contents need to be inside the devices bounds too (even if all sub images/texts are within the bounds of the group being saved).

Changing the group x/y positions means it appears when it gets saved.

group.x = 512

group.y = 512

display.save(group, {filename=“twitter.png”, isFullResolution=true, baseDir=system.DocumentsDirectory})