1截屏:
static public Bitmap takeScreen(final Context ctx,boolean isCuteImage) { View view = ((Activity) ctx).getWindow().getDecorView(); view.destroyDrawingCache(); view.setDrawingCacheEnabled(true); Bitmap bmp = view.getDrawingCache(); if (isCuteImage) {// 截取图片部分 // new bmp = getCuteStatusBarBmp(bmp, ctx); } return bmp;}
/** * 获得剪切掉状态栏的图片 Methods Name: getCuteStatusBarBmp * * @param bmp * @param ctx * @return Comments: * @author Bear Description: */ public static Bitmap getCuteStatusBarBmp(Bitmap bmp, Context ctx) { if (bmp != null) { int statusBarHeight = DeviceInfoUtils.getStatusBarHeight((Activity) ctx); int y = statusBarHeight; int x = 0; int height = bmp.getHeight() - statusBarHeight; int width = bmp.getWidth(); bmp = Bitmap.createBitmap(bmp, x, y, width, height); } return bmp; }new Thread(new Runnable() { @Override public void run() {2压缩: float scaleFactor = 8; Bitmap overlay = Bitmap.createBitmap((int)(cover_blurimg.getWidth()/scaleFactor), (int)(cover_blurimg.getHeight()/scaleFactor), Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(overlay); // canvas.translate(-blur_img.getLeft()/scaleFactor, -blur_img.getTop()/scaleFactor); canvas.scale(1 / scaleFactor, 1 / scaleFactor); Paint paint = new Paint(); paint.setFlags(Paint.FILTER_BITMAP_FLAG); canvas.drawBitmap(cover_blurimg, 0, 0, paint);3模糊: blurimg = Tool.fast_blur(overlay, 25); Log.i("mohuwanbi------------->",""+System.currentTimeMillis()); Message msg = mHandler.obtainMessage(); msg.what=101; mHandler.sendMessageDelayed(msg,10); } }).start();