Android-based long screenshots with content beyond the screen size
Try everything, just stay at the level of imagination, that is also equivalent to waste of time, do not take it for granted
First look at the requirements:
When the content is beyond the display range of the mobile phone, you must intercept all the content to generate the so-called "length ".
There is no difficulty. We use the features of webview and scrollview rendering to generate bitmap.
Main Code:
// This is the public static Bitmap getBitmapByView (scrollview ScrollView) of scrollView {int h = 0; Bitmap bitmap = null; for (int I = 0; I <scrollView. getChildCount (); I ++) {h + = scrollView. getChildAt (I ). getHeight (); scrollView. getChildAt (I ). setBackgroundColor (Color. parseColor ("# ffffff");} bitmap = Bitmap. createBitmap (scrollView. getWidth (), h, Bitmap. config. RGB_565); final Canvas canvas = new Canvas (bitmap); scrollView. draw (canvas); return bitmap;}/*** mScrollView ** @ param context * @ param scrollView */public static void scrollviewContent2Png (Context context, ScrollView scrollView) {Bitmap bmp = null; bmp = getBitmapByView (scrollView); saveBitmapToCamera (context, bmp, null );}
// This Is A webview. The webview's apiprivate static Bitmap captureWebView (WebView webView) {Picture snapShot = webView is used. capturePicture (); Bitmap bmp = Bitmap. createBitmap (snapShot. getWidth (), snapShot. getHeight (), Bitmap. config. ARGB_8888); Canvas canvas = new Canvas (bmp); snapShot. draw (canvas); return bmp ;}
Simple ?....
The code is rough and only implements the function part. When the image is generated, no threads are used. If there are other good solutions, you can communicate with each other:
Download the demo
http://download.csdn.net/detail/jarlen/8910051
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.