public static Bitmap matrixBmp(Bitmap bmp, int margin) { int width = bmp.getWidth(); int height = bmp.getHeight(); int px = UIUtils.dipToPx(margin); Matrix matrix = new Matrix(); if (width > UIUtils.getWidth() - px) { float scale = ((float) (UIUtils.getWidth() - px) / width); matrix.postScale(scale, scale); } else { matrix.postScale(1, 1); } return Bitmap.createBitmap(bmp, 0, 0, width, height, matrix, true); }
private static Drawable resizeActionIcon(Drawable drawable) { int heightBase = UIUtils.dipToPx(24); int height = (int) (heightBase * UIUtils.getDensity()); Drawable d = ImageUtils.zoomDrawable(drawable, height, height); return d; }