【问题标题】:how to resize image comming from Xml Feed如何调整来自 Xml Feed 的图像大小
【发布时间】:2010-07-07 15:06:17
【问题描述】:

我从 Xml 提要中获取图像,然后在表格单元格中显示它我想要做的是将图像大小调整为我的代码的最小大小 5kb。

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

提前致谢。

【问题讨论】:

    标签: objective-c cocoa-touch uitableview iphone


    【解决方案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();
    

    【讨论】:

      猜你喜欢
      • 2020-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      • 1970-01-01
      相关资源
      最近更新 更多