Byte array shows value but the ImgView.Image shows null in ios

蓝咒 提交于 2020-01-25 20:35:13

问题


I am trying to display an image into UIImageView through this method NSData.FromArray() but it gives an null reference exception my code is the following:

Byte _imgData = GetRawData(_imgPath);  // this method get the byte array of size ([131072]) 
NSData _data = NSData.FromArray(_imgData);
ImgView.Image = UIImage.LoadFromData(_data) //in this _data shows the byte array value but the ImgView.Image shows null 

Byte array get the RLE Compress data.

ImgView.Image = UIImage.LoadFromData(_data)

_data is RLE compress byte data I don't know how I can convert it to IOS supported image format. It gives an error, any suggestions to solve this issue?


回答1:


UIImage.Load* methods will return null if the data (be it a NSData or a filename) is invalid and/or the format is unknown to UIImage.

You'll likely need to use a lower level API to provide some data (e.g. width, height, depth) about any RAW data. Once that's done you can construct an UIImage on top of it.



来源:https://stackoverflow.com/questions/10959297/byte-array-shows-value-but-the-imgview-image-shows-null-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!