Tutorial :displaying images in fix size


in my application images are loaded from rss feed in table cell. they are of variant size how can i fix them to certain size. my code is

    int blogEntryIndex1 = [indexPath indexAtPosition: [indexPath length] -1];    imgstring=[[blogEntries objectAtIndex: blogEntryIndex1] objectForKey: @"image"];  NSURL *url = [NSURL URLWithString:imgstring];      NSData *data = [NSData dataWithContentsOfURL:url];    UIImage *img = [[UIImage alloc] initWithData:data];  cell.imageView.image=img;  

you can view my application screen shot click here

Thanks i will be waiting for your response....


I think I understand what your'e asking...

What you want to do is to resize UIImages.

UIImage* resizeImageToSize(UIImage* image, CGSize size)  {      UIGraphicsBeginImageContext(size);        CGContextRef ctx = UIGraphicsGetCurrentContext();        //Account for flipped coordspace      CGContextTranslateCTM(ctx, 0.0, size.height);      CGContextScaleCTM(ctx, 1.0, -1.0);        CGContextDrawImage(ctx,CGRectMake(0.0f, 0.0f, size.width, size.height), image.CGImage);        UIImage* scaled = UIGraphicsGetImageFromCurrentImageContext();        UIGraphicsEndImageContext();      return scaled;  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »