Hello,

I'm passing a bitmap through a bundle to an activity which I called
cameraView on which the user has access to the camera of the device.
I'd like to overlay that bitmap with transparency using the camera as
the background. Is it possible? to put the bitmap in front of the
camera? And how can I change the transparency level?

Thank you very much

Here is my code:

This is the camview.xml:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android";
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">

<SurfaceView android:id="@+id/surface_camera"
android:layout_width="fill_parent" android:layout_height="10dip"
android:layout_weight="1">

</SurfaceView>

</RelativeLayout>

-----------------

And this is the java:

public class cameraView extends Activity implements
SurfaceHolder.Callback{

        SurfaceView mSurfaceView;
        SurfaceHolder mSurfaceHolder;
        Camera mCamera;
        boolean mPreviewRunning=false;
        private Context mContext = this;

        public void onCreate(Bundle icicle) {
                        super.onCreate(icicle);

                        setContentView(R.layout.camview);
                        Bundle f = getIntent().getExtras();
                        picture = f.getParcelable("bitmap");


                        mSurfaceView = (SurfaceView) 
findViewById(R.id.surface_camera);

                        mSurfaceHolder = mSurfaceView.getHolder();

                        mSurfaceHolder.addCallback(this);

                        
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        }

        @Override
        // Create the Surface and Open the Camera
        public void surfaceCreated(SurfaceHolder holder) {
                mCamera = Camera.open();
        }

        @Override
        // Reacts for camera changes
        public void surfaceChanged(SurfaceHolder holder, int format, int
w,int h) {
                if (mPreviewRunning) {
                        mCamera.stopPreview();
                        }
                        Camera.Parameters p = mCamera.getParameters();
                        p.setPreviewSize(w, h);
                        mCamera.setParameters(p);
                        try {
                        mCamera.setPreviewDisplay(holder);
                        } catch (IOException e) {
                        e.printStackTrace();
                        }
                        mCamera.startPreview();
                        mPreviewRunning = true;
        }

        @Override
        // When the camera is closed
        public void surfaceDestroyed(SurfaceHolder holder) {
                mCamera.stopPreview();
                mPreviewRunning = false;
                mCamera.release();
        }

        // When the picure is taken. This method gives the byte[] of the
picture
        Camera.PictureCallback mPictureCallback = new
Camera.PictureCallback() {

                public void onPictureTaken(byte[] imageData, Camera c) {
                }

                };

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to