问题
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