0
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
}

细节是歌曲细节的对象。在歌曲详细信息中,我有两个具有不同数据类型的函数“setIcon”,一个是 int,另一个是位图。

我正在做的是,如果有一首歌附有专辑封面,我正在显示它。(将其缩放到 150X150 后)

如果不是,我将显示 int 类型的默认图像(存储在 drawable-xxhdpi 尺寸 270X270 中)

我在 HTC 手机上使用了它,并使用了 dimns 的图像。150X150 比 dimns 大。270X270(可能是因为此图像正在根据屏幕尺寸等重新缩放和调整)。但我不想要这个.....我希望它们具有相同的尺寸(150x150)。

我的想法是我可以把这张图片(R.drawable.ab type int)转换成位图,然后使用这个函数重新缩放它

bitmap2 = Bitmap.createScaledBitmap(bitmap2, 150, 150, true);

但我不知道该怎么做.....thanx提前......任何其他解决方案也将不胜感激。

4

1 回答 1

0

我开始知道该怎么做

位图 bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ab);

于 2013-08-09T13:33:56.480 回答