我正在嘗試使用iPhone 4及更高版本在Objective-C中縮放圖像,以便儘快將其發送到服務器。目前全尺寸的圖像已經過時了。調整圖像大小Objective-C
減員我想目前是:
CGSize imageSize;
imageSize = CGSizeMake(484, 888);
UIImage *img = [UIImage imageWithContentsOfFile:path];
UIGraphicsBeginImageContext(imageSize);
[img drawInRect:CGRectMake(0,0,imageSize.width,imageSize.height)];
UIImage* realfrontImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *frontImageData = UIImageJPEGRepresentation(realfrontImage, 1.0);
這給我的320x460我怎麼得到它,我想484x888大小的圖像。
任何幫助將不勝感激。
xcode只是一個編輯器。 – vikingosegundo 2012-04-26 13:40:12
感謝編輯很累。感謝迄今爲止提出的想法。它們與我目前使用的非常相似,當我在服務器上查看它時,我最終得到尺寸爲320x426的圖像 – chrisw 2012-04-26 13:58:53
您確定連接沒有問題嗎?我的意思是,如果上傳到您的服務器受到干擾,它會給您留下未完成的圖像上傳,但是,這將主要影響圖像的高度。 – 2012-04-29 17:57:40