Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Save and show picture
Started by bbk Apr 10 2019 04:54 AM

- - - - -
3 replies to this topic
display.save display.newimagerect
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

bbk

[GLOBAL: userInfoPane.html]
bbk
  • Enthusiast

  • 61 posts
  • Corona SDK

I am capturing a photo and saving it to the system.DocumentDirectory.

 

If I capture a new photo and save it with the same name, the old version of the picture is still displayed, even though the old file is removed 

resultOK, errorMsg = os.remove(thePictureFile);

and the new photo is saved

  local saveOption =           { 
            filename=pictureSavedAs, 
            baseDir=system.DocumentsDirectory, 
            captureOffscreenArea=true, 
            backgroundColor={0,0,0,0} } 


display.save(photo, saveOption)

and when I look in the Project Sandbox - the file has in face been replaced.

 

 

I can even open an Overlay window several minutes later, and pass the filename as a parameter and the old version of the file (that is no longer in the Sandbox) is still displayed.

local showDownloadedPicture =  display.newImageRect(sceneGroup,theFileName,system.DocumentsDirectory,totalWidth, totalHeight);

If I however close and re-open the Composer window, the new file is displayed correctly

 

Is there a "cache" that the Composer window (or Corona) uses, that could be cleared ?

 

 



[TOPIC: post.html]
#2

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 770 posts
  • Corona SDK

I remember this issue with cover images, when creating tracker for spotify.

 

I never found out exactly what is going on, but assumed it was some kind of smart ram cache on devices.

The solution for me was to save and load with new filename.



[TOPIC: post.html]
#3

GrahamRanson

[GLOBAL: userInfoPane.html]
GrahamRanson
  • Contributor

  • 105 posts
  • Corona SDK

We had to get around this in our games, I can't find the post where we asked about it but yea if I remember correctly there is a cache for files.

 

I think we just us os.time() as a suffix for the filename when we save it out so that it's always different. Not nice but it works.



[TOPIC: post.html]
#4

bbk

[GLOBAL: userInfoPane.html]
bbk
  • Enthusiast

  • 61 posts
  • Corona SDK

Thank you both. I do use os.time to save other pictures where the name must not be so specific.

If there is no way around it I will find a workaround using unique names.


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: display.save, display.newimagerect