Merging a camera with an image?

I am trying to make a composite image from the camera preview and ImageViewthat was above it. I have one image that is a transparent png that is set to an image like this

ImageView iv = new ImageView(this);
iv.setImageResource(R.drawable.one);

Then I add it to the frame, which already shows the camera preview (inherits SurfaceView) as follows:

preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(cp); //cp is a reference to a camera preview object
preview.addView(iv);

My picture image:

enter image description here

And on the screen something like this (I had to take a photo from another camera, since the DDMS screenshot did not show the preview only the image and the black screen, I don’t know how relevant it is):

enter image description here

Now my task is to take a picture using the image. I came up with two approaches, both of which I do not know whether they can be or cannot be implemented.

  • , , , - . ?
  • ,
  • , , .

, ? ?

+3
1

, byte[] data jpeg.

  • :

    Bitmap photo = BitmapFactory.decodeByteArray(data, 0, data.length);
    photo = photo.copy(photo.getConfig(), true);
    
  • :

    Bitmap overlay = BitmapFactory.decodeResource(getResources(), R.drawable.one);
    
  • :

    Canvas canvas = new Canvas(photo);
    canvas.drawBitmap(overlay, new Matrix(), null);
    

photo .

+5

All Articles