Played around with this a little and solved it just like Dave Sparks
suggested
Thank you Dave
here is the code


import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.ViewGroup.LayoutParams;

public class TestCameraOverlay extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        requestWindowFeature(Window.FEATURE_NO_TITLE);

        Preview mPreview = new Preview(this);
        DrawOnTop mDraw = new DrawOnTop(this);

        setContentView(mPreview);
        addContentView(mDraw, new LayoutParams
(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    }
}

class DrawOnTop extends View {

        public DrawOnTop(Context context) {
                super(context);
                // TODO Auto-generated constructor stub
        }

        @Override
        protected void onDraw(Canvas canvas) {
                // TODO Auto-generated method stub

                Paint paint = new Paint();
                paint.setStyle(Paint.Style.FILL);
                paint.setColor(Color.BLACK);
                canvas.drawText("Test Text", 10, 10, paint);

                super.onDraw(canvas);
        }

}

//----------------------------------------------------------------------

class Preview extends SurfaceView implements SurfaceHolder.Callback {
    SurfaceHolder mHolder;
    Camera mCamera;

    Preview(Context context) {
        super(context);

        // Install a SurfaceHolder.Callback so we get notified when
the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    public void surfaceCreated(SurfaceHolder holder) {
        // The Surface has been created, acquire the camera and tell
it where
        // to draw.
        mCamera = Camera.open();
        mCamera.setPreviewDisplay(holder);
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when we return, so stop the
preview.
        // Because the CameraDevice object is not a shared resource,
it's very
        // important to release it when the activity is paused.
        mCamera.stopPreview();
        mCamera = null;
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int
w, int h) {
        // Now that the size is known, set up the camera parameters
and begin
        // the preview.
        Camera.Parameters parameters = mCamera.getParameters();
        parameters.setPreviewSize(w, h);
        mCamera.setParameters(parameters);
        mCamera.startPreview();
    }

}




On Jan 31, 9:56 pm, srajpal <[email protected]> wrote:
> sounds good, do you have an example piece of code or can you please
> point me to something.
>
> On Jan 30, 8:44 pm, Dave Sparks <[email protected]> wrote:
>
> > No, you don't draw on the camera preview surface. You create a
> > transparent surface above it in the Z stack and draw on that.
>
> > On Jan 30, 5:31 pm, srajpal <[email protected]> wrote:
>
> > > I checked out the api demo, it helps to place the camera preview on
> > > top of the surface view, but the buffers are handid over to the camera
> > > so anything drawn on the canvas, which is received from the handler,
> > > is ignored.
>
> > > There must be some way.  I just don't know it yet.
>
> > > On Jan 30, 7:27 pm, Dianne Hackborn <[email protected]> wrote:
>
> > > > There is an Api Demo showing how to generally do this with a surface 
> > > > view.
> > > > It's very easy, since SurfaceView essentially operates like any other 
> > > > view
> > > > in terms of compositing.
>
> > > > On Fri, Jan 30, 2009 at 3:48 PM, srajpal <[email protected]> wrote:
>
> > > > > Does someone know how I can overlay an image over the camera preview?
>
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > [email protected]
>
> > > > Note: please don't send private questions to me, as I don't have time to
> > > > provide private support.  All such questions should be posted on public
> > > > forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
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