Android View to Image Capture printScreen(View v)

Here you can find the source of printScreen(View v)

Description

print Screen

Declaration

public static Bitmap printScreen(View v) 

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;

import android.view.View;

public class Main {
    public static byte[] printScreen(View v, int quality) {
        if (quality == -1)
            quality = 100;//  www . j ava 2s.  c  om
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        v.setDrawingCacheEnabled(true);
        v.buildDrawingCache(true);
        Bitmap bitmap = v.getDrawingCache();
        bitmap.compress(Bitmap.CompressFormat.JPEG, quality, baos);
        return baos.toByteArray();
    }

    public static Bitmap printScreen(View v) {
        v.setDrawingCacheEnabled(true);
        v.buildDrawingCache();
        return v.getDrawingCache();
    }
}

Related

  1. captureWebView(WebView webView)
  2. captureWebViewVisibleSize(WebView webView)
  3. convertViewToBitmap(View view)
  4. getBitmapFromView(View view)
  5. printScreen(View v, int quality)
  6. shotScreen(View cv)
  7. view2Bitmap(View view)
  8. view2Bitmap(View view, boolean cache)