Commit 6e864603 authored by Sébastien Toque's avatar Sébastien Toque

fix Thumbnail crop/scale in detailView

parent 50e71daf
......@@ -21,9 +21,9 @@
<ImageView
android:layout_width="match_parent"
android:layout_height="210dip"
android:layout_height="230dip"
android:id="@+id/image"
android:scaleType="centerCrop"
android:scaleType="fitCenter"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
......
......@@ -54,7 +54,8 @@ public class MediaInfoActivity extends Activity {
return;
}
int width = getWindowManager().getDefaultDisplay().getHeight();
int width = Math.min(getWindowManager().getDefaultDisplay().getWidth(),
getWindowManager().getDefaultDisplay().getHeight());
int height = width;
// Get the thumbnail.
......@@ -69,7 +70,7 @@ public class MediaInfoActivity extends Activity {
int top = 0;
for (int i = 0; i < height; i++) {
int pixel = mImage.getPixel(width / 2, i);
if (pixel == 0) {
if (pixel == 0 || pixel == -16777216) {
top = i;
} else {
break;
......@@ -79,7 +80,7 @@ public class MediaInfoActivity extends Activity {
int left = 0;
for (int i = 0; i < width; i++) {
int pixel = mImage.getPixel(i, height / 2);
if (pixel == 0) {
if (pixel == 0 || pixel == -16777216) {
left = i;
} else {
break;
......@@ -87,8 +88,8 @@ public class MediaInfoActivity extends Activity {
}
// Cut off the transparency on the borders
mImage = Bitmap.createBitmap(mImage, top, left,
(width - (2 * top)), (height - (2 * left)));
mImage = Bitmap.createBitmap(mImage, left, top,
(width - (2 * left)), (height - (2 * top)));
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