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