5

I need to take a picture with the camera and at the same time show an overlay image on top of the camera view. After the picture is taken, i need to save what the user saw while taking the picture. Can anyone suggest me? Please.

Santhosh
  • 4,956
  • 12
  • 62
  • 90
  • Did you ever figure this out?? I need to do the same. Have gotten the camera to work with an overlay, but I can't save the two together as one image. – Willem Ellis Dec 23 '11 at 19:12
  • Possible duplicate of [capturing image from camera and overlaying another bitmap before we save it](https://stackoverflow.com/questions/9938801/capturing-image-from-camera-and-overlaying-another-bitmap-before-we-save-it) – Alex Cohn Dec 24 '17 at 20:30

1 Answers1

-1
  public void onPictureTaken(byte[] data, Camera camera){
  Bitmap cameraBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

  wid = cameraBitmap.getWidth();
  hgt = cameraBitmap.getHeight();


 Bitmap newImage = Bitmap.createBitmap(wid , hgt , Bitmap.Config.ARGB_8888);

  Canvas canvas = new Canvas(newImage);

  canvas.drawBitmap(cameraBitmap, 0f, 0f, null);

  Drawable drawable = getResources().getDrawable(R.drawable.d);
  drawable.setBounds(20 ,20, 260, 160);
  drawable.draw(canvas);

  File storagePath = new File(Environment.getExternalStorageDirectory() + "/Vampire Photos/"); 
  storagePath.mkdirs(); 

  File myImage = new File(storagePath,Long.toString(System.currentTimeMillis()) + ".jpg");

  try
  {
    FileOutputStream out = new FileOutputStream(myImage);
    newImage.compress(Bitmap.CompressFormat.JPEG, 90, out);


    out.flush();
    out.close();
  }
  catch(FileNotFoundException e)
  {
   Log.d("In Saving File", e + "");
  }
  catch(IOException e)
  {
    Log.d("In Saving File", e + "");
  }  

  camera.startPreview();

  drawable = null;

  newImage.recycle();
  newImage = null;

  cameraBitmap.recycle();
  cameraBitmap = null;
 } };