List of utility methods to do View to Image Capture
Bitmap | captureWebView(WebView webView) capture Web View Picture snapShot = webView.capturePicture(); Bitmap bmp = Bitmap.createBitmap(snapShot.getWidth(), snapShot.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); snapShot.draw(canvas); return bmp; |
Bitmap | captureWebViewVisibleSize(WebView webView) capture Web View Visible Size Bitmap bmp = webView.getDrawingCache();
return bmp;
|
Bitmap | convertViewToBitmap(View view) convert View To Bitmap view.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
|
Bitmap | getBitmapFromView(View view) get Bitmap From View Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(returnedBitmap); Drawable bgDrawable = view.getBackground(); if (bgDrawable != null) bgDrawable.draw(canvas); else canvas.drawColor(Color.WHITE); ... |
Bitmap | printScreen(View v) print Screen v.setDrawingCacheEnabled(true);
v.buildDrawingCache();
return v.getDrawingCache();
|
byte[] | printScreen(View v, int quality) print Screen if (quality == -1) quality = 100; ByteArrayOutputStream baos = new ByteArrayOutputStream(); v.setDrawingCacheEnabled(true); v.buildDrawingCache(true); Bitmap bitmap = v.getDrawingCache(); bitmap.compress(Bitmap.CompressFormat.JPEG, quality, baos); return baos.toByteArray(); ... |
Bitmap | shotScreen(View cv) shot Screen try { cv.setDrawingCacheEnabled(true); Bitmap bmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bmp); cv.draw(canvas); cv.setDrawingCacheEnabled(false); return bmp; ... |
Bitmap | view2Bitmap(View view) view Bitmap return view2Bitmap(view, false);
|
Bitmap | view2Bitmap(View view, boolean cache) view Bitmap view.setDrawingCacheEnabled(cache);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
|
Bitmap | loadBitmapFromView(View v) load Bitmap From View Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.layout(0, 0, v.getWidth(), v.getHeight()); v.draw(c); return b; |