0

I am using camera preview in my application.It should have a watermark while taking a photo and even after showing the preview also.It should also save the image with that watermark.

I just added Imageview, to show the image while taking photo.

     <FrameLayout android:id="@+id/preview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/button_layout"
        android:layout_below="@+id/middle1">
  </FrameLayout>

  <ImageView android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button_layout"

        android:background="@drawable/fblogo"  />

I can able to keep this image while taking photo and showing preview of image.But it is not saving this watermark.

I think it just working to show the image.How can I add this watermark to image even after taking the image.

This imageview I have added is just showing on my surfaceview,but the image is not saving with this watermark.only the image taken from camera is getting saved.

Thanks

user1871951
  • 105
  • 3
  • 8

1 Answers1

2

You have to make Canvas from the photo taken, and then overlay watermark image on the canvas.

Try to the answer of Declan Shanaghy

Android: How to overlay-a-bitmap/draw-over a bitmap?

Community
  • 1
  • 1
Heejin
  • 4,463
  • 3
  • 26
  • 30
  • I want to add the watermark when the camera gets opened.It should continue in preview and saved photo.How can I add image to surfaceview. – user1871951 Dec 05 '12 at 06:54
  • 1
    @user1871951 You have to implement two things for that. 1. Let the watermark image be floating on the camera preview. For this, try this: http://stackoverflow.com/questions/7466336/android-overlay-on-android-camera-preview. 2. Even though you put overlay image on the camera preview, photos taken don't have watermark image on them. You should implement what I mentioned in the answer: make a canvas from the photo and overlay watermark image on it. – Heejin Dec 05 '12 at 08:07
  • I need to set the canvas at particular position like this, canvas.drawBitmap(bitmap, 0, 500, null); Did this effect on other devices of different size – user1871951 Dec 05 '12 at 10:18
  • 1
    @user1871951 It will depend on the size of the photo taken, which depends on the used device. I recommend you to use relative coordinates when putting the watermark image on the photo something like ``center of the image`` or ``30px less than the bottom right of the image`` – Heejin Dec 05 '12 at 10:48