如何调整来自Xml Feed的图像大小 [英] how to resize image comming from Xml Feed

查看:108
本文介绍了如何调整来自Xml Feed的图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

感谢提前。

推荐答案

尝试这样做,如果它有帮助:

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

这篇关于如何调整来自Xml Feed的图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆