Sometimes display.save doesn't work.

Hi,

I’m using display.save to “capture” and process 8 images.

As you can see on the attachment some images are bad captured with some white lines… Apparently it is not a cause. The code is the same but sometimes all images are perfect and sometimes 1 or 2 are broken like the attach.

Any suggestion or idea about the solution is welcome! THANKS

Hi @jalemanyf,

I don’t see an attachment, can you please provide it? Also, some code for how you’re doing the capture(s) would help a lot for the community/staff to diagnose.

Thanks,

Brent

Hi Brent,

Thanks for your interest.

I have attached the image another time… 

The complete code is very long but I extract the important part. I need a composed png image that contents an image and a text. All this is inserted on a group called ‘quetionGroup’

On the final part I convert this group to a png image using the display.save… but I have got the problems.

I have 8 questions to convert every time. Normally 2 are bad transformed and the other 6 are perfect. The bad images not are the same every time I tried.

Here is the code:

local function createQuestion(filenameQUE)
------------------------------- Image -------------------------------
local questionGroup = display.newGroup()
local imagenCentral
local expImage = combat.soldiers[u].expImage
local margenImagenTexto = 0.6 – margen que se deja entre las imágenes de preguntas/respuestas y el texto inferior

if(expImage~=nil) then
local imageName = aq.imageFromURL(expImage)
–print (’ ---->>> Ruta de la imágen: ’ … imageName)
if(tools.existeFichero(imageName,system.DocumentsDirectory)==true) then
imagenCentral = display.newImage(imageName,system.DocumentsDirectory)
imagenCentral.x = display.contentCenterX + distancia

local prop = aq.imageProportions(imagenCentral,imagesWidth)
imagenCentral.xScale = prop
imagenCentral.yScale = prop
imagenCentral.y = 350 – 350 Modificado para FLIPP
questionGroup:insert(imagenCentral)
else
print("No se ha hallado el fichero de la imagen de la solapa: " … u)
end
else
print("No se ha hallado la imagen de la solapa: " … u)
end

---------------------- Text --------------------------------------------------

local textoPregunta = combat.soldiers[u].questionDesc
local YtextoPregunta = display.contentHeight*.5

if (imagenCentral~=nil) then
YtextoPregunta = imagenCentral.y + imagenCentral.contentHeight * margenImagenTexto
end

if (textoPregunta~=nil) then
local options =
{
text = textoPregunta,
x = display.contentCenterX + distancia,
y = YtextoPregunta,
width = display.contentWidth*0.75,
font = fontName,
fontSize = fontSize,
align = “center” – Alignment parameter
}
local questionDesc = display.newText(options)
questionDesc:setFillColor( darkBlue[1], darkBlue[2], darkBlue[3], darkBlue[4] )
questionGroup:insert(questionDesc)
end

– ====>>> HERE IS THE PROBLEM: Finally, we save the imageGroup into a png image file

local function saveWithDelay()
display.save (questionGroup,{filename = filenameQUE, baseDir = system.DocumentsDirectory, captureOffscreenArea=true, backgroundColor = {backgroundColor[1],backgroundColor[2],backgroundColor[3]}})
print ('Grabando la imagen de la pregunta: ’ … filenameQUE)
questionGroup:removeSelf()

end
timer.performWithDelay( 100, saveWithDelay )

end

Thanks!

Can you make a working demo that shows the problem including a main.lua, build.settings, config.lua and any assets needed so that we can build it and run it on a device?  Put all of that in a zip file (zip only please, no rar, 7z etc.) and share it with us via DropBox or Google Drive link?

Thanks

Rob

Hi Rob and Brent,

It was a little bit difficult to extract the bug part from the complete project… but I finally got it!

As you tell me, I put the complete demostration project on a zip. Here is the link: https://drive.google.com/open?id=0B73OnhxkOLzjX2VNNWxyWG5IR1k

It happens usually with the first image but works perfect on the next 6…

I’m working on Corona Version 2017.3068 (2017.3.31) (not very old)

Thanks to all

Best Regards,

Are you seeing this issue in the simulator or on device? If so what device?

Are you using a Mac or Windows?

I ran your test project on my Mac with both 3068 and 3114 and the 7 images produced all look like I think they should look. I’ll attach a couple here.

Hello Rob,

Thanks for your interest and time.

I’m using the simulator on a MacBook Pro (13 inches, 2016, two Thunderbolt 3 ports).

The Corona Version is: Version 2017.3068 (2017.3.31)

Probably it works fine on the device… I’m going to make more test using a newest version of Corona and different devices.

Regards

I’ve seen the same issue. Will dig out the link…

If you can Horace… any HELP is welcome! Thanks

Hi @jalemanyf,

I don’t see an attachment, can you please provide it? Also, some code for how you’re doing the capture(s) would help a lot for the community/staff to diagnose.

Thanks,

Brent

Hi Brent,

Thanks for your interest.

I have attached the image another time… 

The complete code is very long but I extract the important part. I need a composed png image that contents an image and a text. All this is inserted on a group called ‘quetionGroup’

On the final part I convert this group to a png image using the display.save… but I have got the problems.

I have 8 questions to convert every time. Normally 2 are bad transformed and the other 6 are perfect. The bad images not are the same every time I tried.

Here is the code:

local function createQuestion(filenameQUE)
------------------------------- Image -------------------------------
local questionGroup = display.newGroup()
local imagenCentral
local expImage = combat.soldiers[u].expImage
local margenImagenTexto = 0.6 – margen que se deja entre las imágenes de preguntas/respuestas y el texto inferior

if(expImage~=nil) then
local imageName = aq.imageFromURL(expImage)
–print (’ ---->>> Ruta de la imágen: ’ … imageName)
if(tools.existeFichero(imageName,system.DocumentsDirectory)==true) then
imagenCentral = display.newImage(imageName,system.DocumentsDirectory)
imagenCentral.x = display.contentCenterX + distancia

local prop = aq.imageProportions(imagenCentral,imagesWidth)
imagenCentral.xScale = prop
imagenCentral.yScale = prop
imagenCentral.y = 350 – 350 Modificado para FLIPP
questionGroup:insert(imagenCentral)
else
print("No se ha hallado el fichero de la imagen de la solapa: " … u)
end
else
print("No se ha hallado la imagen de la solapa: " … u)
end

---------------------- Text --------------------------------------------------

local textoPregunta = combat.soldiers[u].questionDesc
local YtextoPregunta = display.contentHeight*.5

if (imagenCentral~=nil) then
YtextoPregunta = imagenCentral.y + imagenCentral.contentHeight * margenImagenTexto
end

if (textoPregunta~=nil) then
local options =
{
text = textoPregunta,
x = display.contentCenterX + distancia,
y = YtextoPregunta,
width = display.contentWidth*0.75,
font = fontName,
fontSize = fontSize,
align = “center” – Alignment parameter
}
local questionDesc = display.newText(options)
questionDesc:setFillColor( darkBlue[1], darkBlue[2], darkBlue[3], darkBlue[4] )
questionGroup:insert(questionDesc)
end

– ====>>> HERE IS THE PROBLEM: Finally, we save the imageGroup into a png image file

local function saveWithDelay()
display.save (questionGroup,{filename = filenameQUE, baseDir = system.DocumentsDirectory, captureOffscreenArea=true, backgroundColor = {backgroundColor[1],backgroundColor[2],backgroundColor[3]}})
print ('Grabando la imagen de la pregunta: ’ … filenameQUE)
questionGroup:removeSelf()

end
timer.performWithDelay( 100, saveWithDelay )

end

Thanks!

Can you make a working demo that shows the problem including a main.lua, build.settings, config.lua and any assets needed so that we can build it and run it on a device?  Put all of that in a zip file (zip only please, no rar, 7z etc.) and share it with us via DropBox or Google Drive link?

Thanks

Rob

Hi Rob and Brent,

It was a little bit difficult to extract the bug part from the complete project… but I finally got it!

As you tell me, I put the complete demostration project on a zip. Here is the link: https://drive.google.com/open?id=0B73OnhxkOLzjX2VNNWxyWG5IR1k

It happens usually with the first image but works perfect on the next 6…

I’m working on Corona Version 2017.3068 (2017.3.31) (not very old)

Thanks to all

Best Regards,

Are you seeing this issue in the simulator or on device? If so what device?

Are you using a Mac or Windows?

I ran your test project on my Mac with both 3068 and 3114 and the 7 images produced all look like I think they should look. I’ll attach a couple here.

Hello Rob,

Thanks for your interest and time.

I’m using the simulator on a MacBook Pro (13 inches, 2016, two Thunderbolt 3 ports).

The Corona Version is: Version 2017.3068 (2017.3.31)

Probably it works fine on the device… I’m going to make more test using a newest version of Corona and different devices.

Regards

I’ve seen the same issue. Will dig out the link…

If you can Horace… any HELP is welcome! Thanks