作者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