Howdy, Stranger!

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

CAMERA to Image?

Hello,
Why CAMERA is not an image?
Someone knows how to make an variable with Camera as Image?

Tagged:

Comments

  • dave1707dave1707 Mod
    edited September 2017 Posts: 7,753

    Here's an example. Use collectgarbage() to prevent Codea from crashing when it updates img.

    displayMode(FULLSCREEN)
    
    function setup()
    end
    
    function draw()
        background(40, 40, 50)
        img=image(CAMERA)
        collectgarbage()
        if img~=nil then
            sprite(img,WIDTH/2,HEIGHT/2)
        end
    end
    
  • Why that doesn't work???


    function setup() end function draw() i = image(CAMERA) collectgarbage() imgCopy = i:copy(i.width/2, i.height/2, 500, 500) end
  • dave1707dave1707 Mod
    Posts: 7,753

    Are you after something like this. Tap the screen to copy a section of the Camera image.

    displayMode(FULLSCREEN)
    
    function setup()
    end
    
    function draw()
        background(0)
        i = image(CAMERA)
        collectgarbage()
        if imgCopy~=nil then
            sprite(imgCopy,WIDTH/2,HEIGHT/2)
        elseif i~=nil then
            sprite(i,WIDTH/2,HEIGHT/2)
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            print(i)
            imgCopy = i:copy(i.width/2, i.height/2, 500, 500)
        end
    end
    
  • Thanks!

Sign In or Register to comment.