Android watermark camera and android watermark

Source: Internet
Author: User

Android watermark camera and android watermark

The watermark camera implemented in this article is similar to the watermark camera function in the QQ space. Because I have read a demo to implement a simple watermark camera function, I think it is quite interesting. On this basis, I modified it, optimized and improved, and added some features to bring them closer to the qq watermark camera function.

Supported functions:

1. switch between the front and rear cameras;

2. Focus on the photo and click on the screen (provided that the focus function is supported on the mobile phone );

3. The camera screen will be adjusted according to the resolution supported by the camera, without the image stretching and deformation;

4. Support modifying mood phrases in watermarks;

:







The watermark actually adds n custom views to Viewpaper and overwrites them to SurfaceView through the frame layout. Saving an image is actually equivalent to screenshots. The main code is as follows:

view.setDrawingCacheEnabled(true);view.buildDrawingCache();Bitmap bitmap = view.getDrawingCache();int width=view.getWidth();int height=view.getHeight();Bitmap b = Bitmap.createBitmap(bitmap, 0, 0, width, height);view.destroyDrawingCache();
View is the parent control of the image position in the Activity that displays the photo result after the photo is taken:

    <RelativeLayout        android:id="@+id/rl_water"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_above="@id/ll_buttom"        android:layout_below="@id/ll_title" >        <ImageView            android:id="@+id/water_photo"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:contentDescription="@string/app_name"            android:scaleType="centerCrop" />        <android.support.v4.view.ViewPager            android:id="@+id/viewPager"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_alignParentBottom="true"            android:layout_marginBottom="10dp" />            </RelativeLayout>

For example, RelativeLayout in this article;

This article provides customized mood text. Other words, such as the city (which can be implemented through location) and name, can all be implemented in a similar way, if you are interested in it, you can implement it by yourself. If you have similar requirements in the project, you can directly use it in the project. Of course, you still need to consider the adaptation of various models!

Source Code address: http://download.csdn.net/detail/baiyuliang2013/8492231


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.