Hi all.
I'm trying to make an application to view some pictures taken from my webiste ("http//toytoy365.com").
I saved the pictures to the system.DocumentsDirectory, and can browse them with display.newImage() method.
I would allow the user to save them to the device album.
Is there any way/method to move files from system.DocumentsDirectory to the album ?
Regards,
Xuan.
Hi,
thank you for your answer.
I tried with the function "display.captureScreen(true)".
But to make some kind of animation, I created an image with display.newImage() wich appear and fade away.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | function beforeSave() image_temp = display.newImage(images_name[imgNum], system.DocumentsDirectory) image_temp.alpha = 0 local scaleImage = 1 if image_temp.width > image_temp.height then scaleImage = screenW/image_temp.width image_temp.xScale = scaleImage image_temp.yScale = scaleImage image_width = math.ceil(image_temp.width*scaleImage) image_height = math.ceil(image_temp.height*scaleImage) else scaleImage = screenH/image_temp.height image_temp.xScale = scaleImage image_temp.yScale = scaleImage image_width = math.ceil(image_temp.width*scaleImage) image_height = math.ceil(image_temp.height*scaleImage) end image_temp.x = images[imgNum].x -- position x of the original image image_temp.y = images[imgNum].y -- position y of the original image transition.to(image_temp, { time=1000, alpha=1, transition=easing.outExpo, onComplete=saveIt } ) end function saveIt() display.captureScreen(true) afterSave() end function afterSave() transition.to(image_temp, { time=1000, x=0, transition=easing.outExpo } ) transition.to(image_temp, { time=1000, y=0, transition=easing.outExpo } ) transition.to(image_temp, { time=1000, alpha=0, transition=easing.outExpo } ) transition.to(image_temp, { time=1000, xScale=0, transition=easing.outExpo } ) transition.to(image_temp, { time=1000, yScale=0, transition=easing.outExpo } ) timer.performWithDelay(400, afterSaveEnd) end function afterSaveEnd() image_temp:removeSelf() transition.to(mainGroup, { time=500, alpha=1, transition=easing.outExpo } ) transition.to(infosGroup, { time=500, alpha=1, transition=easing.outExpo } ) transition.to(btnLess, { time=500, alpha=1, transition=easing.outExpo } ) end |
Regards,
Xuan.
Your afterSave function is doing five transitions on the same image. All five will run in parallel, which I'm not sure is what you intended. You could create one transition that does all the object transitions.
The other problem is your transitions run for 1000 msec (1 second) but you also start a 400 msec timer which will end first and call afterSaveEnd and delete image_temp before the transition timers have finished.
Just in case you are not aware of it, the timer function and transitions happen at the end of the function and do not happen in sequence. All your timers will fire and execute at the same time.
-Tom
Thank you for the answer.
But it doesn't work either.
I tried something else.
Move the buttons "save the picture" and the text (created with display.newText) "out of the screen" by setting ".x = .x + some_big_value" so as to I can see only the picture to make the "display.captureScreen(true)".
But there is some kind of bug. To see it, I set "some_big_value" to 100.
Then here's a screen shot with the bug.

It seems that the function "display.captureScreen(true)" duplicate what there is on the screen ?
Regards,
Xuan.
Re,
In fact, the function display.captureScreen(true) return an image object.
I have to make "screenshot = display.captureScreen(true)", then "screenshot:removeSelf".
Now it works fine.
Regards,
Xuan.
The purpose of display.captureScreen(true) is to capture what is currently displayed on the screen. It returns the image as an object. By setting the parameter to "true", it also saves the image in the device's Album.
Are you finding that it's not working like that?
-Tom
I didn't know that this method return an image as an object. But I have to remove it after using this method.
And I didn't know if it's normal.
Yes, it's another way of creating an image object. Like any display object you need to remove it when you're done.
You could also use display.save(object,filename) to save the display object to a file in the /Documents directory.
-Tom
Okay,
But as they no way to move pictures from /Documents directory to the album's device, I will choose the choose display.captureScreen(true) method to do that.
Now I will wait for Apple's review u_u.
Thanks.
Regards,
Xuan.
You can save photos to the device's album in an indirect way. If you display the photo on the screen, you can use display.captureScreen( true ), and it will save the photo.
-Tom