0

I want to create an app for Android that will be able to access the phone's camera. I know this is possible so that's not a problem. The android developers website gives plenty of information on that. I was wondering is it possible, when i open the camera through my app, can an image (such as a sprite image from a game) be displayed on the screen? so when i take the picture the sprite character is also in the picture. The sprite needs to be on the screen when I open the camera, and that image needs to be saved

Hopefully I've explained what I am trying to do because I can't find any information on this

Karen123456
  • 327
  • 1
  • 3
  • 10

1 Answers1

0

You can display camera preview on SurfaceView, or as a SurfaceTexture in OpenGL. The latter approach lets you add any 3D sophistication to your display, but even a simple SurfaceView may be overlayed by an ImageView, even simply in the layout.xml, e.g.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@null"
                android:windowNoTitle="true">


<SurfaceView 
    android:id="@+id/preview"
    android:background="@null"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

  <ImageView
        android:id="@+id/sprite"
        android:background="@null"
        android:src="@drawable/sprite" 
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelaiveLayout>

You can use an ImageView with transparent background, and a PNG with transparency to display a sprite of exotic shape.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307