Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

set image from media.selectPhoto
Started by skulldred Jun 03 2018 12:33 AM

No replies to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 1 posts
  • Corona SDK

Hi at all


i try to set an image from media.selectPhoto to a display.newCircle.

local Img = display.newCircle( 100, 100, 30 )
function pickImg( event )
  if media.hasSource( media.PhotoLibrary ) then
    media.selectPhoto( { mediaSource=media.PhotoLibrary, listener=onComplete, destination={ baseDir=system.DocumentsDirectory, filename="img.jpg" } } )
    native.showAlert( "Corona", "This device does not have a photo library.", { "OK" } )
local function onComplete()
  timer.performWithDelay(1000, setPic, 1)
local function setPic ()
  local path = system.pathForFile( "img.jpg", system.DocumentsDirectory)
  local paint = {
    type = "image",
    filename = path
  Img.fill = paint
  Img.fill.scaleX = 1

When i pick the first time an image it waits a second and set the picture to the circle.

But if i choose a second time the picture it try to set it immediately and the picture looks wired with lines.

Some times the app crash. i guess that happen cause the picture is still in copy process if i wait a second i have no problems.


Is there a better way and why the listener is not "reset"? When i choose the picture a second time why


Thanks a lot for ur help.

cheers SD