2010-07-07 43 views
0

我從Xml提要獲取圖像,然後在表格單元格中顯示它我想要做的是將圖像大小調整爲我的代碼的最小大小爲5kb。如何調整圖像來自Xml飼料

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]; 

在此先感謝。

回答

1

試試這個,如果有幫助:

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