List of usage examples for android.graphics Bitmap createBitmap
public static Bitmap createBitmap(@Nullable DisplayMetrics display, @NonNull @ColorInt int colors[], int width, int height, @NonNull Config config)
From source file:Main.java
private static Bitmap createLargeToSmallBitmap(int widthBitmap, int heightBitmap, int widthTarget, int heightTarget, Bitmap bitmap) { int x = (widthBitmap - widthTarget) / 2; int y = (heightBitmap - heightTarget) / 2; return Bitmap.createBitmap(bitmap, x, y, widthTarget, heightTarget); }
From source file:Main.java
public static Bitmap clip(Resources resources, int drawable, int x, int y, int width, int height) { Bitmap resource = BitmapFactory.decodeResource(resources, drawable); return Bitmap.createBitmap(resource, x, y, width, height); }
From source file:Main.java
/** * Utility function to resize bitmap to a square * /*from w w w. ja v a2 s.c o m*/ * @param bitmap the bitmap to crop * @return the cropped bitmap */ public static Bitmap cropBitMapToSquare(Bitmap bitmap) { int shortSideLen = Math.min(bitmap.getHeight(), bitmap.getWidth()); return Bitmap.createBitmap(bitmap, 0, 0, shortSideLen, shortSideLen); }
From source file:Main.java
public static Bitmap changeImageColor(Bitmap sourceBitmap, int color) { Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1); Paint p = new Paint(); p.setColor(color);/* ww w. j a v a 2 s.co m*/ ColorFilter filter = new LightingColorFilter(color, 1); Canvas canvas = new Canvas(resultBitmap); canvas.drawBitmap(resultBitmap, 0, 0, p); return resultBitmap; }
From source file:Main.java
private static Bitmap getSquareBitmap(Bitmap srcBitmap) { int size = Math.min(srcBitmap.getWidth(), srcBitmap.getHeight()); int paddingX = (srcBitmap.getWidth() - size) / 2; int paddingY = (srcBitmap.getHeight() - size) / 2; return Bitmap.createBitmap(srcBitmap, paddingX, paddingY, size, size); }
From source file:Main.java
public static Bitmap getCanvasBitmap(Bitmap bm, int width, int height) { int w = bm.getWidth(); int h = bm.getHeight(); if (w < width || h < height) { Log.e("bitmaputils", "bitmap target size is not "); return bm; }/*w w w . ja v a 2s. co m*/ Bitmap bitmap = Bitmap.createBitmap(bm, (w - width) / 2, (h - height) / 2, width, height); return bitmap; }
From source file:Main.java
public static Bitmap cutImage(Bitmap src, int cutY) { //DLOG.d("choices", "cutImage!!"); int bit_x, bit_y, bit_width, bit_height; bit_y = cutY;/*from ww w. ja v a 2 s . c om*/ bit_height = src.getHeight() - 2 * bit_y; bit_width = bit_height * 10 / 16; bit_x = (src.getWidth() - bit_width) / 2 + 1; return Bitmap.createBitmap(src, bit_x, bit_y, bit_width, bit_height); }
From source file:Main.java
public static Bitmap[] splitBitmap(Bitmap pic, int row, int col) { int tileWidth = pic.getWidth() / col; int tileHeight = pic.getHeight() / row; Bitmap[] tiles = new Bitmap[row * col]; for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { tiles[r * col + c] = Bitmap.createBitmap(pic, c * tileWidth, r * tileHeight, tileWidth, tileHeight); }/* w w w.j av a 2 s. c o m*/ } return tiles; }
From source file:Main.java
public static Bitmap getCircularBitmapImage(Bitmap source) { int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() - size) / 2; int y = (source.getHeight() - size) / 2; Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); if (squaredBitmap != source) { source.recycle();/*from w ww . j a va 2s . c o m*/ } Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); paint.setShader(shader); paint.setAntiAlias(true); float r = size / 2f; canvas.drawCircle(r, r, r, paint); squaredBitmap.recycle(); return bitmap; }
From source file:Main.java
public static Bitmap changeBitmapColor(@NonNull Bitmap sourceBitmap, @IntegerRes int color) { Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1); Paint p = new Paint(); ColorFilter filter = new LightingColorFilter(color, 1); p.setColorFilter(filter);/*from w w w . ja va2 s . c o m*/ Canvas canvas = new Canvas(resultBitmap); canvas.drawBitmap(resultBitmap, 0, 0, p); return resultBitmap; }