Hi,
I have modified the widget demo to let me pick and display a photo from the photo library and is partly working but it has problems. It is probably because I am taking code from several examples. Anyway, here are the problems:
-
I can pick the photo but it displays twice, one at the origin and the other correctly where I wanted in the thumbnail. Where is this other photo coming from.
-
Both photos stay even though I go on to other widgets. I have tried removeself() and it gives an error on this img.
-
I am supposed to be saving the photo in the system.DocumentsDirectory but I cannot find the file anywhere on my laptop. I really don’t need to save it but the example code I am using uses it and I can’t seem to not use it because I then get an error in the thumbnail display.
Here is the code:
local function sessionComplete ( event )
local photo = event.target
local baseDir = system.DocumentsDirectory
display.save(photo, "photo.jpg", baseDir)
end
local function newphoto ( event )
clearGroup( demoGroup )
-- choose photo library for picture
media.show( media.SavedPhotosAlbum, sessionComplete )
-- create scrollView widget
scrollBox = widget.newScrollView{
--top = display.statusBarHeight + titleBar.height,
width = 320,
height = 366,
maskFile = "assets/wallpaper.jpg"
}
-- insert widget into demoGroup
demoGroup:insert( scrollBox.view )
-- Create thumbnail
local thumbnail = display.newGroup()
local baseDir = system.DocumentsDirectory
local img = display.newImage("photo.jpg",baseDir)
thumbnail:insert( img, true )
img:scale( 0.5, 0.5 )
local r = 5
local border = display.newRoundedRect( 0, 0, img.contentWidth + 2\*r, img.contentHeight + 2\*r, r )
border:setFillColor( 0,255,255,200 )
thumbnail:insert( 1, border, true )
thumbnail:translate( 0.5\*display.contentWidth, 0.5\*display.contentHeight )
end
And here is the display
I cannot seem to paste the image of the display. How do you paste an image here. I do a copy but can’t paste !
[import]uid: 95689 topic_id: 19141 reply_id: 319141[/import]
[import]uid: 52491 topic_id: 19141 reply_id: 74500[/import]