Access the camera of a Smartphone using libGDX

Posted by PH-zero on Stack Overflow See other posts from Stack Overflow or by PH-zero
Published on 2014-08-19T09:13:19Z Indexed on 2014/08/20 4:22 UTC
Read the original article Hit count: 174

Filed under:
|
|

I searched the web, browsed through the libGDX wiki, but without success. My Question: Is there a way, to access the camera of smartphones, let the user take a photo, and then store the image in a Texture-instance?

I could imagin something like this:

@Override
public void onCamTrigger(){
    ApplicationType appType = Gdx.app.getType();
    switch (appType) {
    case Android: case iOS:
        Texture someTexture = new Texture(Gdx.input.getCamera().getImage());
        //do something with the Texture instance...
        someTexture.dispose();
        break;
    default:
        break;
    }
}

Of course this is pure fiction! I know that there's a lot more to this like opening the camera, displaying it, then take a photo etc. . But is there a convenience method like this? If so, how does it work? On Android, i think i could implement it without using any convenience methods offered by libGDX, but i have no idea on how this works on iOS =/

© Stack Overflow or respective owner

Related posts about camera

Related posts about libgdx