display.save not saving image or loading problem?

Hi,

We are building an app for our newspaper that lets a user submit a photo with a caption, except I seem to be having trouble either saving or loading their image. The app takes the picture just fine, but when I go to reload the user’s image/caption, there is no photo. Here is what I have for that part of the code:

– save image from the camera
local sessionComplete = function(event)
local t = event.target
t.x = display.contentWidth/2
t.y = display.contentHeight/2
tv=display.newGroup()
tv:insert(t)
local baseDir = system.DocumentsDirectory
display.save( tv, “nctpic.jpg”, baseDir)
transition.to( tv, { time=500, delay=50, xScale=.13, yScale=.13, x=374, y=44 } )
inputGroup:insert(tv)
end

– load the picture from the user’s project
local function getPicture()
photoPath = system.pathForFile( “nctpic.jpg”, system.DocumentsDirectory )
local t = display.newImage(photoPath)
if t then
t.x = display.contentWidth/2
t.y = display.contentHeight/2
tv:insert(t)
transition.to( tv, { time=500, delay=500, xScale=.13, yScale=.13, x=374, y=44} )
inputGroup:insert(tv)
projectBody.text=“picture loaded”
else
projectBody.text=“no picture loaded”
end
end

I am testing on an iPod touch right now, with software version 4.3.1, and I am using Corona SDK 2011.484.

Any ideas?
Thanks!

[import]uid: 50201 topic_id: 9907 reply_id: 309907[/import]

try calling display.captureScreen( ) to capture the screen and save the resulting image

http://developer.anscamobile.com/node/2467

local f = display.captureScreen()

display.save(f…)

c. [import]uid: 24 topic_id: 9907 reply_id: 36168[/import]

btw: there is a bug on display.save on groups we that is on our bugbase and engineering is aware of the bug. [import]uid: 24 topic_id: 9907 reply_id: 36171[/import]

Hi Carlos,

Thanks for the info! I’ll give display.captureScreen a go, I appreciate the help. [import]uid: 50201 topic_id: 9907 reply_id: 36365[/import]

Somehow I missed the part about there being a bug with display.save on groups, and sure enough I can’t get this to work at all, even though I am not adding the screencap to a group. In fact, the following code causes the whole app to hang on the device, in the simulator it just saves a blank image:

local screenCap = display.captureScreen( false )
local baseDir = system.DocumentsDirectory
display.save( screenCap, pic, baseDir)

I’m using
Corona Version 2011.533 (2011.4.12)
xCode version 4.0.2
testing on an iPod touch with software version 4.3.1

There must be some way to do this, all I want to do is save the picture to a directory and retrieve it later. I am storing the name of the image along with other details in a database, that’s all working fine. Any ideas? Can someone share a piece of code that accomplishes saving and retrieving an image? Or am I waiting on a bug fix?
[import]uid: 50201 topic_id: 9907 reply_id: 39849[/import]

what happens if you save the image to the album?

display.captureScreen(true)

does it show up on the album?

c [import]uid: 24 topic_id: 9907 reply_id: 39853[/import]

Hi Carlos,

Thanks for the help. Passing ‘true’ the app still freezes up, the image is saved to the album but the dimensions are wrong. [import]uid: 50201 topic_id: 9907 reply_id: 39967[/import]

Hello,

I have got quite similar problem. All I need to do is to save DiplayObject (loaded from gallery via media.show()) into a png file - I am trying to make a local copy of image before sending it to server.

I tried to use both - display.save() and display.captureScreen(). Both of those methods are saving corrupted images. Original image is landscape and have got 1024 x 768 dimensions. The saved image have got inverse dimensions 768 x 1024, but it is still landscape. So the image is cropped on sides and bottom part of image have got a new black strip.

Note, that app runs in Landscape-right mode. I tried both - save image as standalone DisplayObject and save image as part of DisplayGroup. Both methods gave me same result.

On simulator app behaves correctly as expected, this issue appears only on device. (iPad)
Is there any chance to be fixed it soon? Is the bug already in bugbase? (This issue is blocking release of app. I don’t have any Idea for any workaround.)

Thanks a lot.
Radim [import]uid: 52745 topic_id: 9907 reply_id: 45174[/import]