Here you can find the source of getTrimmedTop(Bitmap img, int border)
Parameter | Description |
---|---|
img | a parameter |
border | a parameter |
public static int getTrimmedTop(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 2 s. c om * returns blank area of the image to the up direction of the image * @param img * @return blank area of the image to the up direction of the image */ public static int getTrimmedTop(Bitmap img) { int width = img.getWidth(); int height = img.getHeight(); int data = height; for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { if (img.getPixel(i, j) != Color.TRANSPARENT && j < data) { data = j; break; } } } return data; } /** * returns blank area of the image to the up direction of the image * @param img * @param border * @return blank area of the image to the up direction of the image */ public static int getTrimmedTop(Bitmap img, int border) { int width = img.getWidth(); int height = img.getHeight(); int data = height; for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { if (img.getPixel(i, j) != Color.TRANSPARENT && j < data) { data = j; break; } } } return data + border; } }