I’m building an app which allows access to a device’s built-in photo library so a user can choose a photo to illustrate a product.
Once the photo is chosen, it’s copied into the apps system.DocumentDirectory folder. There are points in my app where I need to access all of the photos which have been previously chosen by the user so I can display them in a scroll view.
But, I’m having problems referencing the saved images when I create a new display.newImageRect. My current code is below, the loop scans the Documents dir for all *.jpg files and should then create the image rect from the discovered filename, anyone got any idea what I’m doing wrong here? (I’ve removed a load of supporting code that wasn’t necessary)
ta
Chris
local doc\_path = system.pathForFile( "", system.DocumentsDirectory ) local imgFileCount = 0 for file in lfs.dir( doc\_path ) do if ( string.sub( file, -4, -1 ) ) == ".jpg" then local pathToFile = system.pathForFile( file, system.DocumentsDirectory ) local bg = display.newImageRect( "images/various/photo-film.png", 176, 160 ) local fg = display.newImageRect( pathToFile, 158, 102 ) end end