我正在尝试以250x250的大小获取当前正在播放的iPod艺术品的PNG表示。但是我继续获得640x640的图像。代码如下。任何人都可以指出我正在制造的无疑的骨头错误吗?
- (NSData *) getNowPlayingPng
{
// Assume that there is no artwork for the media item.
UIImage *artworkImage = [[UIImage alloc]init];
// Get the artwork from the current media item, if it has artwork.
MPMediaItemArtwork *artwork = [iPodController.nowPlayingItem valueForProperty: MPMediaItemPropertyArtwork];
// Obtain a UIImage object from the MPMediaItemArtwork object
if (artwork) {
artworkImage = [artwork imageWithSize:CGSizeMake(250.00, 250.00)];
}
NSData *pngimage = UIImagePNGRepresentation(artworkImage);
return pngimage;
}
答案 0 :(得分:1)
我正在做类似的事情,并使用相同的代码为artworkImage。是否有特定原因需要转换为PNG?我只是使用UIImageView组件来显示图稿。
MPMediaItemArtwork *artwork = [self.nowPlaying valueForProperty: MPMediaItemPropertyArtwork];
self.audioImageView.image = [artwork imageWithSize:(CGSizeMake(320, 320))];