如何在iphone sdk中显示UIImageJPEGRepresentation图像
我想使用 UIImageJPEGRepresentation 在 iphone 中添加图像,在下面的代码中我缺少一些我不知道如何添加的东西
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:gameObj.gameThumbnails]];
UIImage *myImage=[UIImage imageWithData:data];
imageView.image=UIImageJPEGRepresentation(myImage, 90);// I am missing something here
[elementView addSubview:imageView];
[imageView release];
/*gameObj.gameThumbnails is an url like http://static.gamesradar.com/images/mb/GamesRadar/us/Games/X/X-Men%20Arcade/Bulk%20Viewer/360%20PS3/2010-10-11/192.168.30.167-image36_bmp_jpgcopy--game_thumbnail.jpg
*/
请帮助我解决这个问题
I want to use UIImageJPEGRepresentation to add the image in iphone, in below code i am missing some thing I don't know how to add
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:gameObj.gameThumbnails]];
UIImage *myImage=[UIImage imageWithData:data];
imageView.image=UIImageJPEGRepresentation(myImage, 90);// I am missing something here
[elementView addSubview:imageView];
[imageView release];
/*gameObj.gameThumbnails is an url like http://static.gamesradar.com/images/mb/GamesRadar/us/Games/X/X-Men%20Arcade/Bulk%20Viewer/360%20PS3/2010-10-11/192.168.30.167-image36_bmp_jpgcopy--game_thumbnail.jpg
*/
Please help me out of this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你将比较质量设置为 90。它应该在 0.0 到 1.0 之间
u are setting comparison quality to 90. it should be between 0.0 to 1.0
UIImageJPEGRepresentation 函数返回一个 NSData(字节数组),它表示以 JPEG 压缩的图像的内容。
要显示它,只需直接使用 UIImage 即可。
The UIImageJPEGRepresentation function returns an NSData (array of bytes) which represents a content of the image if compressed in JPEG.
To display it, you just need to use the UIImage directly.
确保您:
如果仍然不起作用,请尝试以下操作:
希望它有帮助
Make sure that you:
And if it still doesn't work then try the following:
Hope it helps