I'm trying to get a PNG representation of the currently playing iPod artwork at a size of 250x250. However I keep getting a 640x640 image instead. Code is below. Can anybody point out the doubtless bone-headed mistake I'm making?
- (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 开发者_JAVA百科the MPMediaItemArtwork object
if (artwork) {
artworkImage = [artwork imageWithSize:CGSizeMake(250.00, 250.00)];
}
NSData *pngimage = UIImagePNGRepresentation(artworkImage);
return pngimage;
}
i'm doing something similar and using the same code for the artworkImage. Is there a specific reason you are needing to convert to PNG? I'm just using an UIImageView component to display the artwork.
MPMediaItemArtwork *artwork = [self.nowPlaying valueForProperty: MPMediaItemPropertyArtwork];
self.audioImageView.image = [artwork imageWithSize:(CGSizeMake(320, 320))];
精彩评论