Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there any easy way to allow user access to photo library?

in Questions Posts: 28

Does anyone know of a simple way to allow users to choose an image from their photo library/camera roll? I've read a lot of old posts on the subject, most from over 4 years ago, and I was just wondering if anything has changed in Codea since to allow easier access to the photo picker. If not, which seems very likely, what is the current best known method to allow a user to personally select a photo for use in my app?

Comments

  • Posts: 195

    @Circuit Nope! Sorry. Codea doesn't have a feature like this, tho it would be cool if they implemented it. The only way to do it so to type the code in objective c once you export it to xCode

  • edited March 3 Posts: 28

    Well, that's exactly as I had thought from what I have read. Unfortunately, seeing as my programming skills are kind of lacking outside of Codea, that probably won't be viable option for me. I was really hoping it was possible by now : (

  • dave1707dave1707 Mod
    Posts: 5,810

    @Circuit If you could put your image on a public photo site, they could get the image with code like this.

    displayMode(FULLSCREEN)
    
    function setup()
        getImg()
    end
    
    function draw()
        background(40, 40, 50)
        if img~=nil then
            sprite(img,WIDTH/2,HEIGHT/2,700)
        else
            fill(255)
            text("Loading image",WIDTH/2,HEIGHT/2)
        end
    end
    
    function getImg()
        http.request('https://dl.dropboxusercontent.com/s/3149mj9xjx1w71e/Costa Rican Frog.jpg',gotImage)
    end
    
    function gotImage(image,status,header)
        img=image
    end
    
  • edited March 3 Posts: 28

    @dave1707 , thanks for the creative thinking. That works great for personal use, but I feel it may be kinda weird to request a user post their file online and then input a link into my app to allow their own images to be used. Is there any possible way to use the image copy/paste function, or does that still have the same limitations? Thanks again

  • Posts: 195

    @Circuit That's what I was just about to recommend. You can tell the user to copy the image onto their pasteboard, then when retrieving it:

    function retrieve()
         local img=pasteboard.image()
         assert(img~=nil,"The user doesn't have anything on their pasteboard!")
         return img
    end
    
  • Posts: 28

    @CamelCoder Thanks, that should work just fine for now.

Sign In or Register to comment.