views:

37

answers:

1

Hi

I am getting image from Xml feed and then displaying it in table cell what I want to do is to resize image to minimum size of 5kb 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 autorelease];

Thanks In Advance.

+1  A: 

Try this if it helps :

CGSize itemSize = CGSizeMake(kAppIconWidth, kAppIconHeight);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[image drawInRect:imageRect];
self.cell.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
hib