Example usage for android.view View getDrawingCache

List of usage examples for android.view View getDrawingCache

Introduction

In this page you can find the example usage for android.view View getDrawingCache.

Prototype

@Deprecated
public Bitmap getDrawingCache() 

Source Link

Document

Calling this method is equivalent to calling getDrawingCache(false).

Usage

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

private Bitmap createDraggedChildBitmap(View view) {
    view.setDrawingCacheEnabled(true);/*from  w  ww. j a v  a 2 s.c  o  m*/
    final Bitmap cache = view.getDrawingCache();

    Bitmap bitmap = null;
    if (cache != null) {
        try {
            bitmap = cache.copy(Bitmap.Config.ARGB_8888, false);
        } catch (final OutOfMemoryError e) {
            Log.w(TAG, "Failed to copy bitmap from Drawing cache", e);
            bitmap = null;
        }
    }

    view.destroyDrawingCache();
    view.setDrawingCacheEnabled(false);

    return bitmap;
}

From source file:com.zoffcc.applications.zanavi.Navit.java

static void take_map_screenshot(String dir_name, String name_base) {
    try {/* w  ww.  j a va2s. co m*/
        View v1 = Navit.N_NavitGraphics.view;
        v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(dir_name + "/" + name_base + ".png");
            bm.compress(Bitmap.CompressFormat.PNG, 100, out);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("TSCR:004 " + e.getMessage());
        } finally {
            v1.setDrawingCacheEnabled(false);

            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e4) {
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

static void take_phone_screenshot(Activity a, String dir_name, String name_base) {
    try {/* w  w w  .  ja v a2s  .  c  om*/
        View v1 = a.getWindow().getDecorView().getRootView();
        v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(dir_name + "/" + name_base + ".png");
            bm.compress(Bitmap.CompressFormat.PNG, 100, out);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("TSCR:004 " + e.getMessage());
        } finally {
            v1.setDrawingCacheEnabled(false);

            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e4) {
    }
}