List of usage examples for android.graphics Bitmap createScaledBitmap
public static Bitmap createScaledBitmap(@NonNull Bitmap src, int dstWidth, int dstHeight, boolean filter)
From source file:Main.java
public static int getHighlightColorFromBitmap(final Bitmap bitmap) { int incolor = Color.BLACK; if (null != bitmap) { final Bitmap bitmap1px = Bitmap.createScaledBitmap(bitmap, 1, 1, false); incolor = bitmap1px.getPixel(0, 0); }//from w w w . ja va 2s .com return getHighlightColor(incolor); }
From source file:Main.java
/** * Resize bitmap/* w ww . ja v a 2 s. c o m*/ * @param bitmap * @param width * @param height * @return scaled bitmap */ public static Bitmap resizeBitmap(Bitmap bitmap, int width, int height) { return Bitmap.createScaledBitmap(bitmap, width, height, false); }
From source file:Main.java
static public Bitmap scaleToFill(Bitmap b, int width, int height) { float factorH = height / (float) b.getWidth(); float factorW = width / (float) b.getWidth(); float factorToUse = (factorH > factorW) ? factorW : factorH; return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), false);/* w w w . j a va 2 s . c o m*/ }
From source file:Main.java
public static Bitmap scale(Bitmap bitmap, float scale) { if (bitmap == null) { return null; }/*from w w w . j av a 2 s . c o m*/ int width = Math.max(1, (int) (bitmap.getWidth() * scale)); int height = Math.max(1, (int) (bitmap.getHeight() * scale)); return Bitmap.createScaledBitmap(bitmap, width, height, false); }
From source file:Main.java
public static Bitmap decodeSampledBitmapFromFile(String path, int requiredWidth, int requiredHeight) { if (path == null) { return null; }//www . j ava 2 s .c o m Bitmap bmp = BitmapFactory.decodeFile(path, null); return Bitmap.createScaledBitmap(bmp, requiredWidth, requiredHeight, true); }
From source file:Main.java
public static Bitmap zoomBitmap(Bitmap bitmap, float res) { if (bitmap == null) { return null; }/*from ww w .j a va2s . co m*/ int width, height; width = (int) (bitmap.getWidth() * res); height = (int) (bitmap.getHeight() * res); Bitmap newbmp = Bitmap.createScaledBitmap(bitmap, width, height, true); return newbmp; }
From source file:Main.java
/** * @description get the scaled bitmap as request * * @param src//from ww w .j av a2 s. c om * @param dstWidth * @param dstHeight * @return */ private static Bitmap createScaleBitmap(Bitmap src, int dstWidth, int dstHeight, int inSampleSize) { Bitmap dst = Bitmap.createScaledBitmap(src, dstWidth, dstHeight, false); if (src != dst) { src.recycle(); } return dst; }
From source file:Main.java
public static Bitmap createBitmap(String paramString, int paramInt1, int paramInt2) { Bitmap localBitmap1 = BitmapFactory.decodeFile(paramString); Bitmap localBitmap2 = null;//w w w. j a va 2 s . com if (localBitmap1 != null) { localBitmap2 = Bitmap.createScaledBitmap(localBitmap1, paramInt1, paramInt2, true); localBitmap1.recycle(); } return localBitmap2; }
From source file:Main.java
public static Bitmap scaleToFill(Bitmap bitmap, int i, int j) { float f = (float) j / (float) bitmap.getWidth(); float f1 = (float) i / (float) bitmap.getWidth(); float f2;/* w ww . j a v a2s. c o m*/ if (f > f1) { f2 = f1; } else { f2 = f; } return Bitmap.createScaledBitmap(bitmap, (int) (f2 * (float) bitmap.getWidth()), (int) (f2 * (float) bitmap.getHeight()), false); }
From source file:Main.java
public static Bitmap scaleDown(Bitmap bmp, float maxImgSize, boolean filter) { float ratio = Math.min((float) maxImgSize / bmp.getWidth(), (float) maxImgSize / bmp.getHeight()); int width = Math.round((float) ratio * bmp.getWidth()); int height = Math.round((float) ratio * bmp.getHeight()); return Bitmap.createScaledBitmap(bmp, width, height, filter); }