Exemple #1
0
 public static global::haxe.crypto.Adler32 read(global::haxe.io.Input i)
 {
     unchecked {
                         #line 61 "C:\\HaxeToolkit\\haxe\\std\\haxe\\crypto\\Adler32.hx"
         global::haxe.crypto.Adler32 a = new global::haxe.crypto.Adler32();
         int a2a = i.readByte();
                         #line 63 "C:\\HaxeToolkit\\haxe\\std\\haxe\\crypto\\Adler32.hx"
         int a2b = i.readByte();
         int a1a = i.readByte();
                         #line 65 "C:\\HaxeToolkit\\haxe\\std\\haxe\\crypto\\Adler32.hx"
         int a1b = i.readByte();
         a.a1 = ((a1a << 8) | a1b);
                         #line 67 "C:\\HaxeToolkit\\haxe\\std\\haxe\\crypto\\Adler32.hx"
         a.a2 = ((a2a << 8) | a2b);
         return(a);
     }
                 #line default
 }
Exemple #2
0
        public virtual global::haxe.io.Bytes readPixels(int width, int height, bool interlaced)
        {
            unchecked {
                global::haxe.io.Input input  = this.i;
                int pixelsCount              = (width * height);
                global::haxe.io.Bytes pixels = global::haxe.io.Bytes.alloc(pixelsCount);
                int minCodeSize              = input.readByte();
                int blockSize     = (input.readByte() - 1);
                int bits          = input.readByte();
                int bitsCount     = 8;
                int clearCode     = (1 << minCodeSize);
                int eoiCode       = (clearCode + 1);
                int codeSize      = (minCodeSize + 1);
                int codeSizeLimit = (1 << codeSize);
                int codeMask      = (codeSizeLimit - 1);
                global::haxe.root.Array <object> baseDict = new global::haxe.root.Array <object>();
                {
                    int _g1 = 0;
                    int _g  = clearCode;
                    while ((_g1 < _g))
                    {
                        int i = _g1++;
                        baseDict[i] = new global::haxe.root.Array <int>(new int[] { i });
                    }
                }

                global::haxe.root.Array <object> dict = new global::haxe.root.Array <object>();
                int dictLen = (clearCode + 2);
                global::haxe.root.Array <int> newRecord = null;
                int i1   = 0;
                int code = 0;
                int last = default(int);
                while ((i1 < pixelsCount))
                {
                    last = code;
                    while ((bitsCount < codeSize))
                    {
                        if ((blockSize == 0))
                        {
                            break;
                        }

                        bits      |= (input.readByte() << bitsCount);
                        bitsCount += 8;
                        --blockSize;
                        if ((blockSize == 0))
                        {
                            blockSize = input.readByte();
                        }
                    }

                    code       = (bits & codeMask);
                    bits     >>= codeSize;
                    bitsCount -= codeSize;
                    if ((code == clearCode))
                    {
                        dict          = baseDict.copy();
                        dictLen       = (clearCode + 2);
                        codeSize      = (minCodeSize + 1);
                        codeSizeLimit = (1 << codeSize);
                        codeMask      = (codeSizeLimit - 1);
                        continue;
                    }

                    if ((code == eoiCode))
                    {
                        break;
                    }

                    if ((code < dictLen))
                    {
                        if ((last != clearCode))
                        {
                            newRecord = ((global::haxe.root.Array <int>)(global::haxe.root.Array <object> .__hx_cast <int>(((global::haxe.root.Array)(dict[last]))))).copy();
                            newRecord.push(((global::haxe.root.Array <int>)(global::haxe.root.Array <object> .__hx_cast <int>(((global::haxe.root.Array)(dict[code])))))[0]);
                            dict[dictLen++] = newRecord;
                        }
                    }
                    else
                    {
                        if ((code != dictLen))
                        {
                            throw global::haxe.lang.HaxeException.wrap(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat("Invalid LZW code. Excepted: ", global::haxe.lang.Runtime.toString(dictLen)), ", got: "), global::haxe.lang.Runtime.toString(code)));
                        }

                        newRecord = ((global::haxe.root.Array <int>)(global::haxe.root.Array <object> .__hx_cast <int>(((global::haxe.root.Array)(dict[last]))))).copy();
                        newRecord.push(newRecord[0]);
                        dict[dictLen++] = newRecord;
                    }

                    newRecord = ((global::haxe.root.Array <int>)(global::haxe.root.Array <object> .__hx_cast <int>(((global::haxe.root.Array)(dict[code])))));
                    {
                        int _g2 = 0;
                        while ((_g2 < newRecord.length))
                        {
                            int item = newRecord[_g2];
                            ++_g2;
                            pixels.b[i1++] = ((byte)(item));
                        }
                    }

                    if (((dictLen == codeSizeLimit) && (codeSize < 12)))
                    {
                        ++codeSize;
                        codeSizeLimit = (1 << codeSize);
                        codeMask      = (codeSizeLimit - 1);
                    }
                }

                while ((blockSize > 0))
                {
                    input.readByte();
                    --blockSize;
                    if ((blockSize == 0))
                    {
                        blockSize = input.readByte();
                    }
                }

                while ((i1 < pixelsCount))
                {
                    pixels.b[i1++] = ((byte)(0));
                }

                if (interlaced)
                {
                    global::haxe.io.Bytes buffer = global::haxe.io.Bytes.alloc(pixelsCount);
                    int offset = this.deinterlace(pixels, buffer, 8, 0, 0, width, height);
                    offset = this.deinterlace(pixels, buffer, 8, 4, offset, width, height);
                    offset = this.deinterlace(pixels, buffer, 4, 2, offset, width, height);
                    this.deinterlace(pixels, buffer, 2, 1, offset, width, height);
                    pixels = buffer;
                }

                return(pixels);
            }
        }