Conversion of RLE to UIImageView.Image in IOS
-
13-06-2021 - |
Frage
How I can convert RLE image data to IOS compatible image format (that is supported by IOS)
ImgView.Image = UIImage.LoadFromData(_data) // _data contains of size 1350124
_data contains the byte array of image in RLE format. while is assign to ImgView.Image it gets
null. so image is not display on UIImageView.
how to make _data compatible format with UIImage
Lösung
after implementing RLE Algorithm just i code below few line of code long struggle finally I got it solution
Byte _imgData = GetRawData(_imgPath); // this method get the byte array of size ([131072])
NSData _data = NSData.FromArray(_imgData);
ImgView.Image = UIImage.LoadFromData(_data)
int rawWidth = PixelData.ImageWidth;
int rawHeight = PixelData.ImageHeight;
float[] _rawSize = new float[rawWidth * rawHeight * 4];
for (int i =0; i < rawWidth * rawHeight; ++i) {
_rawSize [4 * i] = (float)(1.0 / 255.0);
_rawSize [4 * i + 1] = (float)(1.0 / 255.0);
_rawSize [4 * i + 2] = (float)(1.0 / 255.0);
_rawSize [4 * i + 3] = 255;
}
int bitsPerComponant = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4 * rawWidth;
CGDataProvider _provider = new CGDataProvider (_imgData, 0, _imgData.Length);
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB ();
CGImage cg = new CGImage (
rawWidth,
rawHeight,
bitsPerComponant,
bitsPerPixel,
bytesPerRow,
colorSpace,
CGBitmapFlags.ByteOrderDefault,
_provider,
null,
true,
CGColorRenderingIntent.Default
);
ImgView.Image = UIImage.FromImage (cg);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow