Android Utililty Methods View to Image Capture

List of utility methods to do View to Image Capture

Description

The list of methods to do View to Image Capture are organized into topic(s).

Method

BitmapcaptureWebView(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;
BitmapcaptureWebViewVisibleSize(WebView webView)
capture Web View Visible Size
Bitmap bmp = webView.getDrawingCache();
return bmp;
BitmapconvertViewToBitmap(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;
BitmapgetBitmapFromView(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);
...
BitmapprintScreen(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();
...
BitmapshotScreen(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;
...
Bitmapview2Bitmap(View view)
view Bitmap
return view2Bitmap(view, false);
Bitmapview2Bitmap(View view, boolean cache)
view Bitmap
view.setDrawingCacheEnabled(cache);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
return bitmap;
BitmaploadBitmapFromView(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;