Commit 4e4fd68a authored by Sébastien Toque's avatar Sébastien Toque
Browse files

crop thumbnails in video list

parent e6949432
......@@ -128,6 +128,7 @@ public class ThumbnailerManager extends Thread {
continue;
thumbnail.copyPixelsFromBuffer(ByteBuffer.wrap(b));
thumbnail = Util.cropBorders(thumbnail, width, height);
Log.i(TAG, "Thumbnail created!");
......
......@@ -99,6 +99,33 @@ public class Util {
return bitmap;
}
public static Bitmap cropBorders(Bitmap bitmap, int width, int height)
{
int top = 0;
for (int i = 0; i < height; i++) {
int pixel = bitmap.getPixel(width / 2, i);
if (pixel == 0 || pixel == -16777216) {
top = i;
} else {
break;
}
}
int left = 0;
for (int i = 0; i < width; i++) {
int pixel = bitmap.getPixel(i, height / 2);
if (pixel == 0 || pixel == -16777216) {
left = i;
} else {
break;
}
}
// Cut off the transparency on the borders
return Bitmap.createBitmap(bitmap, left, top,
(width - (2 * left)), (height - (2 * top)));
}
public static String getValue(Context context, String string, int defaultId)
{
return (string != null && string.length() > 0) ? string : context.getString(defaultId);
......
......@@ -97,29 +97,7 @@ public class MediaInfoActivity extends ListActivity {
return;
mImage.copyPixelsFromBuffer(ByteBuffer.wrap(b));
int top = 0;
for (int i = 0; i < height; i++) {
int pixel = mImage.getPixel(width / 2, i);
if (pixel == 0 || pixel == -16777216) {
top = i;
} else {
break;
}
}
int left = 0;
for (int i = 0; i < width; i++) {
int pixel = mImage.getPixel(i, height / 2);
if (pixel == 0 || pixel == -16777216) {
left = i;
} else {
break;
}
}
// Cut off the transparency on the borders
mImage = Bitmap.createBitmap(mImage, left, top,
(width - (2 * left)), (height - (2 * top)));
mImage = Util.cropBorders(mImage, width, height);
mHandler.sendEmptyMessage(NEW_IMAGE);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment