Madan Mohan
Madan Mohan

Reputation: 8810

How to display the UIImageJPEGRepresentation image in iphone sdk

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

Upvotes: 2

Views: 14516

Answers (3)

Novarg
Novarg

Reputation: 7440

Make sure that you:

  • Set your compression quality to 0.9(it MUST be between 0.0 - 1.0)
  • Set the frame of the UIImageView correctly
  • Don't make that UIImageView hidden

And if it still doesn't work then try the following:

[elementView bringSubviewToFront:imageView];

Hope it helps

Upvotes: 0

kennytm
kennytm

Reputation: 523184

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.

imageView.image = myImage;

Upvotes: 3

iOSPawan
iOSPawan

Reputation: 2894

u are setting comparison quality to 90. it should be between 0.0 to 1.0

Upvotes: 13

Related Questions