Android的Bitmap看起来挺好用,下面的代码只是大致思路,未必能运行,性能也是呵呵哒,切勿当真
Bitmap bitmap = BitmapFactory.decodeFile("src.png");
int top = 0, right = 0, bottom = 0, left = 0;
int w = bitmap.getWidth();
int h = bitmap.getHeight();
for (int i = 0; i < h; i++) {
boolean blank = true;
for (int j = 0; j < w; i++) {
int color = bitmap.getPixel(j, i);
if (Color.alpha(color) != 0xff) {
blank = false;
}
}
if (blank) {
top++;
}
blank =true;
for (int j = 0; j < w; i++) {
int color = bitmap.getPixel(j, h-i-1);
if (Color.alpha(color) != 0xff) {
blank = false;
}
}
if (blank) {
<