CORONA BUG - display.capture does not work on images larger than screen size

Happy to help!

One more thing.  One of our QA guys here verified that display.capture*() with the “saveToPhotoLibrary” argument set to true will actually save the captured are outside of the screen at the correct resolution to file just like how display.save() does it.  The issue is that the image displayed is downscaled.

Also, if you’re displaying your captured image file via display.newImage() still, then make sure to set the “isFullResolution” argument to true in that function as well.  Otherwise OS X and iOS will automatically downscale the loaded image to fit within the bounds of the screen.  You might be getting burned by this.  Note that you don’t have to worry about this with display.newImageRect().

   https://docs.coronalabs.com/api/library/display/newImage.html#syntax

okay guys. run this code and it explains the entire problem with display.save and steps you through how display.save() is broken and how in 30 seconds you can witness the problem I’m having in my App.

display.setStatusBar(display.HiddenStatusBar)
display.setDefault( “anchorX”, 0 )
display.setDefault( “anchorY”, 0 )
W=display.contentWidth
H=display.contentHeight
local ts=“What we have here is a colored grid that is 2 screens wide and 2 screens high. Move grid around to see that it’s larger than one screen.”
TextObject=display.newText({text=ts,x=0,y=0,width=W,height,0,font=native.systemFont,fontSize=H*.05,align=“left”})
–====================================================================
function saveAsImage()
    TextObject:removeEventListener(“touch”,saveAsImage)
    – save the display group
    local gw=G_grid.width
    local gh=G_grid.height
    
    display.save( G_grid, { filename=“entireGroup.png”, baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={0,0,0,0} } )
    
    – delete original display objects and group now that we have saved the file
    local a
    for a=1,#G_grid do
        display.remove(D_grid)
    end
    display.remove(G_grid)
    G_grid=nil
    
    – now load the image and scale it down as defined by variable ‘sc’
    local img = display.newImage(“entireGroup.png”, system.DocumentsDirectory)
    local sc=50  – % percent of scale after load
    local ts=“This displays the saved image at”…sc…"%. When set to 50%, this should fill screen, because 50% of 2x2 screens is a 1x1 filled screen. "
    ts=ts…"However, if you analyze the ‘entireGroup.png’ file, you will see that it was saved with the proper resolution. "
    ts=ts…“However, only what is visible on the screen at the time of the save is actually visible in the file itself.”
    ts=ts…“This is not evident in a ‘preview’ program, but loading the ‘entireGroup.png’ file up in photoshop makes this clear.\n\n”
    ts=ts…“Also, the loaded Image Resolution of “…img.width…“x”…img.height…” is actually smaller than the saved image file resolution of “…gw…“x”…gh…” because the non-displayed area which wasn’t visible on screen at the time of the display.save was transparent and is cropped when loaded.”
    TextObject.text=ts
    TextObject:toFront()
    img.x = (W*.5)-(gw*sc*.01*.5)
    img.y = (H*.5)-(gh*sc*.01*.5)
    img.width=gw*sc*.01
    img.height=gh*sc*.01
    
    – this code allows you to move the newly loaded image around to see it’s size
    local imgX,imgY,touchX,touchY,x,y  --allow us to scroll and see the height of the example
    local function scroll(event)
        if event.phase==“began” then
            imgX=img.x
            imgY=img.y
            touchX=event.x
            touchY=event.y
        elseif event.phase==“moved” then
            if (imgY~=nil and touchY~=nil) or (imgX~=nil and touchX~=nil) then
                x=imgX-(touchX-event.x)
                y=imgY-(touchY-event.y)
                img.x=x
                img.y=y
            end
        elseif event.phase==“ended” then
            imgX=nil
            imgY=nil
        end
    end
    img:addEventListener(“touch”,scroll)
end
TextObject:addEventListener(“touch”, saveAsImage)
–====================================================================
function createGrid()
    – create grid to see the position of field
    G_grid=display.newGroup()
    D_grid={}
    local z1,z2,x,y
    for z1=1,20 do
        for z2=1,20 do
            if anchor==0 then
                x=(z1-.5)*(W*.1)
                y=(z2-.5)*(H*.1)
            else
                x=(z1-.5)*(W*.1)
                y=(z2-.5)*(H*.1)
            end
            – create obj in grid
            D_grid[#D_grid+1]=display.newRect(x,y,W*.1,H*.1)
            D_grid[#D_grid]:setFillColor(z1*.05,z2*.05,(z1+z2)*.025)
            
            – add object to group
            G_grid:insert(D_grid[#D_grid])
        end
    end
    --because the grid is 2 screens wide and high, let’s center what we see on group
    G_grid.x=-W*.5
    G_grid.y=-H*.5
    
    – this code allows us to scroll the grid around, since it is larger than one screen
    local img=G_grid
    local imgX,imgY,touchX,touchY,x,y  --allow us to scroll and see the height of the example
    function scrollGrid(event)
        if event.phase==“began” then
            imgX=img.x
            imgY=img.y
            touchX=event.x
            touchY=event.y
        elseif event.phase==“moved” then
            if (imgY~=nil and touchY~=nil) or (imgX~=nil and touchX~=nil) then
                x=imgX-(touchX-event.x)
                y=imgY-(touchY-event.y)
                img.x=x
                img.y=y
            end
        elseif event.phase==“ended” then
            imgX=nil
            imgY=nil
            TextObject.text=“You can keep moving the image around if you like, but when you are ready, click on this text object to perform the display.save and display.newImage - after which the code will reload the saved image at 50% resolution. This can be adjusted in the code by modifying the variable ‘sc’.”
            TextObject:toFront()            
        end
    end
    G_grid:addEventListener(“touch”,scrollGrid)
end
–====================================================================
createGrid()
TextObject:toFront()
 

I have the project in zip file if you’d like me to post it as a bug, again.

Go ahead and file it as a bug report. We also need your config.lua and build.settings.

Rob

The full code has been submitted as a bug

(Case 43011) Display.save doesn’t save anything not visible on screen with fullResolution=true

The topic should probably be modified to say:

(Case 43011) Display.save doesn’t save anything not located within the visible view on screen with isfullResolution=true

The coded line that doesn’t work is:

    display.save( G_grid, { filename=“entireGroup.png”, baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={0,0,0,0} } )

…where “G_grid” is a display group of objects.

This is my idea. (-:

display.setDefault("anchorX", 0) display.setDefault("anchorY", 0) local bg = display.newRect(0, 0, display.actualContentWidth, display.actualContentHeight) bg:setFillColor(1, 0, 0, 1) local myObject1 = display.newRect( 0, 0, 100, 150 ) myObject1:setFillColor(0, 0, 1, 1) local ggg = display.newGroup() local g2 = display.newGroup() local gr = display.newRect(g2, 0, 0, 1, 1) gr:setFillColor(0, 0, 0, 0) local myObject2 = display.newCircle( g2, 1000, 1000, 30 ) myObject2:setFillColor(0, 0, 1, 1) g2.x, g2.y = -(g2.width - myObject2.width), -(g2.height - myObject2.height) local group = display.newGroup() group:insert( myObject1 ) group:insert( ggg ) local function cc() display.save( g2, { filename="g2.png", baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={1,1,0,0} } ) local copy = display.newImage(ggg, "g2.png", system.DocumentsDirectory) g2:removeSelf() display.save( group, { filename="entireGroup.png", baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={1,1,0,0} } ) local combined = display.newImageRect("entireGroup.png", system.DocumentsDirectory, 100, 100) group:removeSelf() end timer.performWithDelay(100, cc, 1)