字节数组显示值,但 ImgView.Image 在 ios 中显示为空 [英] Byte array shows value but the ImgView.Image shows null in ios
问题描述
我正在尝试通过此方法 NSData.FromArray()
将图像显示到 UIImageView
中,但它给出了一个空引用异常,我的代码如下:
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
字节数组获取 RLE 压缩数据.
Byte array get the RLE Compress data.
ImgView.Image = UIImage.LoadFromData(_data)
_data 是 RLE 压缩字节数据我不知道如何将其转换为 IOS 支持的图像格式.它给出了一个错误,有什么解决这个问题的建议吗?
_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?
推荐答案
UIImage.Load*
方法将返回 null
如果数据(无论是 NSData
或文件名)无效和/或 UIImage
不知道格式.
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
.
您可能需要使用较低级别的 API 来提供有关任何 RAW 数据的一些数据(例如宽度、高度、深度).完成后,您可以在其上构建一个 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.
这篇关于字节数组显示值,但 ImgView.Image 在 ios 中显示为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!