I am running the code below. It is suppose to save an image to my Documents directory then redirect me to another screen. However, it is saving the image before the image resizes. I tested this part of my app last month when I was working on it, but after finishing up the other sections for some reason it is not working anymore. Here is the code I was working with:
[lua]sessionComplete = function(event)
thePhoto = event.target
thePhoto.x = 0.5 * display.contentWidth
thePhoto.y = 0.5 * display.contentHeight
display.save( thePhoto, “thephoto.jpg”, system.DocumentsDirectory)
if thePhoto then
local w = thePhoto.width
local h = thePhoto.height
print( “w,h = “… w …”,” … h )
end
thePhoto.isVisible = false
director:changeScene(“screen1”,“crossfade”)
end[/lua]
It is suppose to size it to the display, position it, save it, hide it, the redirect the user to another screen. It does everything but resize it.
So I tried this code:
[lua]sessionCompleted = function(event)
if (event.target ~= nil) then
thePhoto = event.target
– Scale and move the image to fit on display completely
thePhoto.w = 384
thePhoto.h = 512
thePhoto.x = 0.5 * display.contentWidth
thePhoto.y = 0.5 * display.contentHeight
thePhoto.isVisible = true
– save it
if (thePhoto.w == 384) then
display.save( thePhoto, “thephoto.jpg”, system.DocumentsDirectory)
director:changeScene(“screen1”,“crossfade”)
thePhoto.isVisible = false
end
if thePhoto then
local w = event.target.width
local h = event.target.height
print( “w,h = “… w …”,” … h )
end
end
end[/lua]
It still doesn’t work. How can I make the app wait for the image to be sized then save it? I thought if I check the width it would work, but I believe it is not really checking the width it is just looking at the value I stated.
Any help or ideas?
Thanks,
Rich [import]uid: 25595 topic_id: 13350 reply_id: 313350[/import]