【发布时间】:2021-04-14 07:36:29
【问题描述】:
从某个时候开始,我得到了这个错误。在 API21- 所有工作文件上,在 API24 上一切正常,API29+ 损坏,未测试其他文件,可能有人知道发生了什么或改变了吗?
这里的代码很简单:
@Nullable
Bitmap getImage() {
if (!isMediaFileExist()) return null;
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
try {
mediaMetadataRetriever.setDataSource(getMediaFile().getFullPath());
} catch (RuntimeException e) {
return null;
}
byte[] imageByte = mediaMetadataRetriever.getEmbeddedPicture(); #MIN API 8
if (imageByte == null) return null;
return BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length);
}
源函数变大了,但这个可爱的部分也不起作用。
Bitmap 以标准方式分配给 ImageView。
结果我看到了图片的一部分和灰色背景。
所有 mp3 都发生过这种情况。在 API21 上,一切看起来都还不错。
例如,我已尝试进行测试以进行 BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length-16384); 并且具有灰色背景的图像的相同部分。看起来 lib 遇到错误。但在 PC 上,在 photoShop、Paint 等图片中看起来不错。十六进制编辑器中的标题看起来不错。
MP3 封面是标准 JPEG,53Kb,大约 300x300 像素,但我认为大小无关紧要,所有 mp3 都会出现这种情况
【问题讨论】: