views:

76

answers:

2

Hi Guys,

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

A: 

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

pawan.mangal
Can you please explain with code how to display .jpeg url image in iphone
Madan Mohan
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:gameObj.gameThumbnails]]; UIImage *myImage=[UIImage imageWithData:data]; imageView.image=myImage;
pawan.mangal
I have done same thing but image is of type .jpg. UIIMage support .jpg type. then how come it is not working.
Madan Mohan
+1  A: 

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;
KennyTM
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:gameObj.gameThumbnails]]; UIImage *myImage=[UIImage imageWithData:data]; imageView.image=[UIImage imageWithData:UIImageJPEGRepresentation(myImage, 0.9)]; [elementView addSubview:imageView]; [imageView release];
Madan Mohan