开发者

how to resize image comming from Xml Feed

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 blog开发者_如何学编程EntryIndex1 = [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.


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜