List of utility methods to do Bitmap Crop
Bitmap | createCenterCropBitmap(Bitmap srcBitmap, int dstWidth, int dstHeight, boolean tryRecycleSource) create Center Crop Bitmap if (srcBitmap == null || dstWidth == 0 || dstHeight == 0) { return srcBitmap; int srcWidth = srcBitmap.getWidth(); int srcHeight = srcBitmap.getHeight(); Bitmap dstBitmap = srcBitmap; try { if ((dstHeight / dstWidth) - (srcHeight / srcWidth) > 0) { ... |
Bitmap | crop(Bitmap bitmap, float newWidth, float newHeight) Crop. int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); ... |
Bitmap | crop(Bitmap bitmap, int x, int y, float newWidth, float newHeight) Crop from 4 sides. Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, x, y, (int) newWidth, (int) newHeight, null, true); return resizedBitmap; |
Bitmap | cropBitmapToSquare(Bitmap bitmap, int squareLength) crop Bitmap To Square if (bitmap != null) { int imageSquareLength = Math.min(bitmap.getWidth(), bitmap.getHeight()); int croppedLength = Math.min(imageSquareLength, squareLength); float scale = (float) croppedLength / imageSquareLength; Matrix matrix = new Matrix(); matrix.setScale(scale, scale); try { ... |
Bitmap | cropBitmapToSquare(String bitmapPath, int squareLength) crop Bitmap To Square Bitmap bitmap = decodeSampledBitmapFromFile(bitmapPath,
squareLength, squareLength);
return cropBitmapToSquare(bitmap, squareLength);
|
int | getTrimmedBottom(Bitmap img) returns blank area of the image to the downward direction of the image int width = img.getWidth(); int height = img.getHeight(); int data = 0; for (int i = 0; i < width; ++i) { for (int j = height - 1; j >= 0; --j) { if (img.getPixel(i, j) != Color.TRANSPARENT && j > data) { data = j; break; ... |
int | getTrimmedBottom(Bitmap img, int border) returns blank area of the image to the downward direction of the image int width = img.getWidth(); int height = img.getHeight(); int data = 0; for (int i = 0; i < width; ++i) { for (int j = height - 1; j >= 0; --j) { if (img.getPixel(i, j) != Color.TRANSPARENT && j > data) { data = j; break; ... |
int | getTrimmedLeft(Bitmap img) returns blank area of the image to the left direction of the image int width = img.getWidth(); int height = img.getHeight(); int data = width; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { if (img.getPixel(j, i) != Color.TRANSPARENT && j < data) { data = j; break; ... |
int | getTrimmedLeft(Bitmap img, int border) returns blank area of the image to the left direction of the image int width = img.getWidth(); int height = img.getHeight(); int data = width; for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { if (img.getPixel(j, i) != Color.TRANSPARENT && j < data) { data = j; break; ... |
int | getTrimmedRight(Bitmap img) returns blank area of the image to the right direction of the image int width = img.getWidth(); int height = img.getHeight(); int data = 0; for (int i = 0; i < height; ++i) { for (int j = width - 1; j >= 0; --j) { if (img.getPixel(j, i) != Color.TRANSPARENT && j > data) { data = j; break; ... |