iOS从远程地址获取图片并修改尺寸

下面是来客网 jb51.cc 通过网络收集整理的代码片段。

来客网小编现在分享给大家,也给大家做个参考。

NSString* imageURL = [NSString stringWithFormat: @"http://theimageurl.com/?id=%@",[[resultsEntries objectAtIndex:0] objectForKey: @"image_large"]];
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]];   
UIImage* image = [[UIImage alloc] initWithData:imageData];

// resize image
CGSize newSize = CGSizeMake(100,100);
UIGraphicsBeginImageContext( newSize );// a CGSize that has the size you want
[image drawInRect:CGRectMake(0,newSize.width,newSize.height)];

//image is the original UIImage
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();        

imageHeight = image.size.height;
[imageMain setImage:newImage];
[imageData release];
[image release];

以上是来客网(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。

以上是来客网为你收集整理的iOS从远程地址获取图片并修改尺寸全部内容,希望文章能够帮你解决iOS从远程地址获取图片并修改尺寸所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。