mmr.setDataSource(files[i].getPath());
rawArt = mmr.getEmbeddedPicture();//rawart is of type byte
if ( rawArt != null)
{
bitmap2=BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo);
bitmap2 = Bitmap.createScaledBitmap(bitmap2, 150, 150, true);
detail.setIcon(bitmap2);//seticon here is of bitmap type
}
else {
detail.setIcon(R.drawable.ab);//seticon here is of bitmap type
}
细节是songdetails的对象。 在songdetails中, 我有两个函数“setIcon”具有不同的数据类型 一个是int,另一个是位图。
我正在做的是如果附有一首歌的专辑封面,我正在显示它。(在缩放到150X150之后)
如果不是我正在显示int类型的默认图像(存储在drawable-xxhdpi维度270X270中)
我在htc手机和昏暗的图像上使用它。 150X150比dimns大。 270X270(也许是因为这个图像正在根据屏幕尺寸重新调整和调整等)。但我不希望这个......我希望它们具有相同的尺寸(150x150)。
我所想的是我可以拍摄此图像(R.drawable.ab类型int)将其转换为位图,然后使用此函数重新缩放它
bitmap2 = Bitmap.createScaledBitmap(bitmap2, 150, 150, true);
但是我不知道怎么做.....在提前..还有其他任何解决方案都会受到赞赏。
答案 0 :(得分:0)
我知道该怎么做
位图bmp = BitmapFactory.decodeResource(getResources(),R.drawable.ab);