Android MediaMetadata image on lockscreen is zoomed
Asked Answered
C

1

1

When playing media, I am able to place media image onto a lockscreen via

RemoteControlClient.MetadataEditor editor = remoteControlClient.editMetadata(true);
editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, bitmap);

or

MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap);

however, if I use landscape source image (16:9) and lockscreen orientation is potrait, the background image is zoomed (pan and scan) instead of letter boxed. Is there any api I can use to force the scaling method, or the system will render the image only this way?

Campinas answered 9/4, 2015 at 15:59 Comment(0)
M
0

I have faced the same issue (on phone lockscreen and on Android Auto), I have not found the solution yet but I think that you can do a trick :

Add a transparent padding on top and above to your Bitmap to fit the lock screen, here is the code which makes your bitmap square, you can inspire from it to make your bitmap fit the screen ratio :

public static Bitmap createSquaredBitmap(Bitmap srcBmp) {               

    int dim = Math.max(srcBmp.getWidth(), srcBmp.getHeight());
    Bitmap dstBmp = Bitmap.createBitmap(dim, dim, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(dstBmp);
    canvas.drawColor(Color.TRANSPARENT);
    canvas.drawBitmap(srcBmp, (dim - srcBmp.getWidth()) / 2, (dim - srcBmp.getHeight()) / 2, null);

    return dstBmp;
}
Mohr answered 10/6, 2016 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.