以下方法我生病嘗試,但圖像不能正常顯示,它讓損失如何將圖像轉換爲base64而無需在swift 2.0中丟失圖像?
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
img_View.image = info[UIImagePickerControllerOriginalImage] as? UIImage
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
let imageData:NSData = UIImagePNGRepresentation(image)!
strImage = imageData.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
print(strImage)
dismissViewControllerAnimated(true, completion: nil)
}
這裏有損圖像Corrupted image here 雖然我我得到完整的圖像略有模糊圖像解碼成我的電腦,但是當我發送我的base64字符串服務(WEBAPI)(Windows PC),他們只得到一半的圖像。有人可以幫助我如何解決這個問題
你是什麼意思「沒有正確顯示」?你的意思是'strImage'不打印出編碼的圖像嗎? – Fonix
@Fonix,他我得到像半像的空間圖像被損壞。 –
也許'Encoding64CharacterLineLength'選項會干擾使用該base64數據的任何內容,請不要嘗試使用任何選項 – Fonix