【问题标题】:How to Resize image before downloading it to iphone如何在将图像下载到 iPhone 之前调整其大小
【发布时间】:2011-08-05 12:38:00
【问题描述】:

我正在从服务器下载图像并将它们本地保存在我的 iphone 中,但有时图像太大。例如(2500 * 3200)。我想在将其下载到 iphone 之前将大小减小到 300*500。我该怎么做。请帮助我。提前致谢

+(void)DownloadImage:(NSString*)ImagePath{

    if ([ImagePath isEqualToString:@""])
        return;

    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[IMAGEURL stringByAppendingPathComponent:ImagePath]]];

    NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    [data writeToFile:[docDir stringByAppendingPathComponent:ImagePath] atomically:YES];        

}

【问题讨论】:

  • 为什么不在服务器上调整大小并下载调整大小的图像?

标签: iphone


【解决方案1】:

如果您没有选择在服务器上缩小它(这会更好)。

然后看看这个: Any code/library to scale down an UIImage?

这应该使您能够下载图像,然后将其缩小,然后将其保存到手机等。

【讨论】:

    猜你喜欢
    • 2018-07-11
    • 2016-09-30
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多