Merge "Load video thumbnails using ARGB_8888 for quality." into rvc-dev am: eadf939db8
Change-Id: I3c0ac729c94902bd52a8ed21554b01a315d5acf9
This commit is contained in:
@@ -34,6 +34,7 @@ import android.graphics.ImageDecoder.ImageInfo;
|
|||||||
import android.graphics.ImageDecoder.Source;
|
import android.graphics.ImageDecoder.Source;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.media.MediaMetadataRetriever.BitmapParams;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.CancellationSignal;
|
import android.os.CancellationSignal;
|
||||||
@@ -365,6 +366,9 @@ public class ThumbnailUtils {
|
|||||||
return ImageDecoder.decodeBitmap(ImageDecoder.createSource(raw), resizer);
|
return ImageDecoder.decodeBitmap(ImageDecoder.createSource(raw), resizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final BitmapParams params = new BitmapParams();
|
||||||
|
params.setPreferredConfig(Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
final int width = Integer.parseInt(mmr.extractMetadata(METADATA_KEY_VIDEO_WIDTH));
|
final int width = Integer.parseInt(mmr.extractMetadata(METADATA_KEY_VIDEO_WIDTH));
|
||||||
final int height = Integer.parseInt(mmr.extractMetadata(METADATA_KEY_VIDEO_HEIGHT));
|
final int height = Integer.parseInt(mmr.extractMetadata(METADATA_KEY_VIDEO_HEIGHT));
|
||||||
// Fall back to middle of video
|
// Fall back to middle of video
|
||||||
@@ -376,11 +380,11 @@ public class ThumbnailUtils {
|
|||||||
// return a frame without up-scaling it
|
// return a frame without up-scaling it
|
||||||
if (size.getWidth() > width && size.getHeight() > height) {
|
if (size.getWidth() > width && size.getHeight() > height) {
|
||||||
return Objects.requireNonNull(
|
return Objects.requireNonNull(
|
||||||
mmr.getFrameAtTime(thumbnailTimeUs, OPTION_CLOSEST_SYNC));
|
mmr.getFrameAtTime(thumbnailTimeUs, OPTION_CLOSEST_SYNC, params));
|
||||||
} else {
|
} else {
|
||||||
return Objects.requireNonNull(
|
return Objects.requireNonNull(
|
||||||
mmr.getScaledFrameAtTime(thumbnailTimeUs, OPTION_CLOSEST_SYNC,
|
mmr.getScaledFrameAtTime(thumbnailTimeUs, OPTION_CLOSEST_SYNC,
|
||||||
size.getWidth(), size.getHeight()));
|
size.getWidth(), size.getHeight(), params));
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
throw new IOException("Failed to create thumbnail", e);
|
throw new IOException("Failed to create thumbnail", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user