开发者

Getting PNG of currently playing iPod artwork at defined size

开发者 https://www.devze.com 2023-04-03 06:50 出处:网络
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 b

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))]; 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号