Here you can find the source of getTrimmedRight(Bitmap img, int border)
Parameter | Description |
---|---|
img | a parameter |
border | a parameter |
public static int getTrimmedRight(Bitmap img, int border)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Color; public class Main { /**//from ww w. j a v a 2s . c o m * returns blank area of the image to the right direction of the image * @param img * @return blank area of the image to the right direction of the image */ public static int getTrimmedRight(Bitmap img) { 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; } } } return data; } /** * returns blank area of the image to the right direction of the image * @param img * @param border * @return blank area of the image to the right direction of the image */ public static int getTrimmedRight(Bitmap img, int border) { 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; } } } return data + border; } }