0

RLE 画像データを IOS 互換の画像形式 (IOS でサポートされている) に変換する方法

ImgView.Image = UIImage.LoadFromData(_data) // _data contains of size 1350124

_data には、RLE 形式のイメージのバイト配列が含まれます。while は ImgView.Image に割り当てられます

ヌル。そのため、画像はUIImageViewに表示されません。

UIImageで_data互換フォーマットにする方法

4

1 に答える 1

2

RLEアルゴリズムを実装した後、数行のコードの下にコードを書くだけで、長い闘争がついに解決しました

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);
于 2012-06-13T13:24:09.297 に答える