作者GoodTauSo (创业维艰)
看板MacDev
标题[问题] 缩小图片解析度
时间Thu Dec 12 00:21:15 2013
原po使用nsdata存取网路图片,用uiimage呈现在tableview上.
经常因图片太大,很容易记忆体不足当掉.
有没有方法可以将nsdata里的图片缩小,降低bytes?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.137.213.249
1F:→ howdiun:UIGraphicsBeginImageContext(smallSize); 12/12 09:32
2F:→ howdiun:[image drawInRect:imageRect]; 12/12 09:32
3F:→ howdiun:sImage = UIGraphicsGetImageFromCurrentImageContext(); 12/12 09:33
4F:→ howdiun:UIGraphicsEndImageContext(); 12/12 09:33
5F:→ howdiun:not the best way, but a simple way 12/12 09:34
6F:推 fightword:另一个问题 有没有办法可以侦测到图太大的错误 12/12 12:48
7F:→ fightword:以避免程式会crash 12/12 12:48
8F:→ tom19830924:didReceiveRespose可以取得图的大小 12/12 16:42
9F:→ tom19830924:[response expectedContentLength] 12/12 16:42
10F:→ tom19830924:可以在图太大的话[connection cancel] 12/12 16:44