List of usage examples for android.graphics Bitmap createBitmap
public static @NonNull Bitmap createBitmap(@NonNull Picture source)
From source file:Main.java
public static Bitmap getBitmap(View view) { view.setDrawingCacheEnabled(true);/*from w w w .j a v a 2 s .c om*/ Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
public static Bitmap takeScreenShot(View view) { view.setDrawingCacheEnabled(true);//w ww . j av a 2 s .c om view.buildDrawingCache(true); Bitmap res = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return res; }
From source file:Main.java
public static Bitmap getViewBitmap(View view) { view.setDrawingCacheEnabled(true);//w ww . j a v a 2s.c o m Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); view.destroyDrawingCache(); return bitmap; }
From source file:Main.java
public static Bitmap getBitmapForVisibleRegion(WebView webview) { Bitmap returnedBitmap = null;/*w w w.j ava2s .c om*/ webview.setDrawingCacheEnabled(true); returnedBitmap = Bitmap.createBitmap(webview.getDrawingCache()); webview.setDrawingCacheEnabled(false); return returnedBitmap; }
From source file:Main.java
public static Bitmap loadBitmapFromView(View v) { v.setDrawingCacheEnabled(true);//w w w . j av a2 s . c om v.buildDrawingCache(true); // creates immutable clone Bitmap b = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); // clear drawing cache return b; }
From source file:Main.java
/** * Duplicates a bitmap. This does <b>not</b> recycle the original bitmap after the method is called * @param bm The bitmap you wish to duplicate * @return The new bitmap//from w w w . ja v a 2 s. c o m */ public static Bitmap duplicate(Bitmap bm) { Bitmap newBitmap = Bitmap.createBitmap(bm); return newBitmap; }
From source file:Main.java
public static Bitmap setBrightness(Bitmap srcBitmap, int brightness) { Bitmap bitmap = Bitmap.createBitmap(srcBitmap); ColorMatrix cm = new ColorMatrix(new float[] { 1, 0, 0, 0, brightness, 0, 1, 0, 0, brightness, 0, 0, 1, 0, brightness, 0, 0, 0, 1, 0 }); Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(srcBitmap, 0, 0, paint); return bitmap; }
From source file:Main.java
public static Bitmap setContrast(Bitmap srcBitmap, float contrast) { Bitmap bitmap = Bitmap.createBitmap(srcBitmap); ColorMatrix cm = new ColorMatrix( new float[] { contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, contrast, 0, 0, 0, 0, 0, 1, 0 }); cm.setSaturation(contrast);/* w w w . jav a 2 s . com*/ Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(srcBitmap, 0, 0, paint); return bitmap; }
From source file:Main.java
/** * Returns a bitmap from the views drawing cache. Warining: disables drawing * cache after usage./*from w ww . j a v a 2s. c o m*/ * * @param view * @return */ public static Bitmap getBitmapFromView(View view) { view.setDrawingCacheEnabled(true); view.layout(0, 0, view.getWidth(), view.getBottom()); view.buildDrawingCache(); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
public static Bitmap convertViewToBitmap(View v) { v.setDrawingCacheEnabled(true);/*w ww . j a va2 s.com*/ v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.buildDrawingCache(true); Bitmap b = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); // clear drawing cache return b; }