示例#1
0
        public virtual global::format.gif.Block readExtension()
        {
            unchecked {
                int subId = this.i.readByte();
                switch (subId)
                {
                case 1:
                {
                    if ((this.i.readByte() != 12))
                    {
                        throw global::haxe.lang.HaxeException.wrap("Incorrect size of Plain Text Extension introducer block.");
                    }

                    int tmp  = this.i.readUInt16();
                    int tmp1 = this.i.readUInt16();
                    int tmp2 = this.i.readUInt16();
                    int tmp3 = this.i.readUInt16();
                    int tmp4 = this.i.readByte();
                    int tmp5 = this.i.readByte();
                    int tmp6 = this.i.readByte();
                    int tmp7 = this.i.readByte();
                    global::haxe.io.BytesOutput buffer = new global::haxe.io.BytesOutput();
                    global::haxe.io.Bytes       bytes  = global::haxe.io.Bytes.alloc(255);
                    int len = this.i.readByte();
                    while ((len != 0))
                    {
                        this.i.readBytes(bytes, 0, len);
                        buffer.writeBytes(bytes, 0, len);
                        len = this.i.readByte();
                    }

                    buffer.flush();
                    bytes = buffer.getBytes();
                    buffer.close();
                    object __temp_stmt5 = null;
                    {
                        string __temp_odecl1 = bytes.toString();
                        __temp_stmt5 = new global::haxe.lang.DynamicObject(new int[] { 1291439277 }, new object[] { __temp_odecl1 }, new int[] { 31706958, 89406858, 555415130, 853386981, 853386982, 1539378591, 1740766879, 1991808755 }, new double[] { ((double)(tmp4)), ((double)(tmp7)), ((double)(tmp3)), ((double)(tmp)), ((double)(tmp1)), ((double)(tmp5)), ((double)(tmp6)), ((double)(tmp2)) });
                    }

                    global::format.gif.Extension __temp_stmt4 = global::format.gif.Extension.EText(__temp_stmt5);
                    return(global::format.gif.Block.BExtension(__temp_stmt4));
                }


                case 249:
                {
                    if ((this.i.readByte() != 4))
                    {
                        throw global::haxe.lang.HaxeException.wrap("Incorrect Graphic Control Extension block size!");
                    }

                    int packed = this.i.readByte();
                    global::format.gif.DisposalMethod disposalMethod = null;
                    int _g = (((packed & 28)) >> 2);
                    switch (_g)
                    {
                    case 0:
                    {
                        disposalMethod = global::format.gif.DisposalMethod.UNSPECIFIED;
                        break;
                    }


                    case 1:
                    {
                        disposalMethod = global::format.gif.DisposalMethod.NO_ACTION;
                        break;
                    }


                    case 2:
                    {
                        disposalMethod = global::format.gif.DisposalMethod.FILL_BACKGROUND;
                        break;
                    }


                    case 3:
                    {
                        disposalMethod = global::format.gif.DisposalMethod.RENDER_PREVIOUS;
                        break;
                    }


                    default:
                    {
                        disposalMethod = global::format.gif.DisposalMethod.UNDEFINED((((packed & 28)) >> 2));
                        break;
                    }
                    }

                    object __temp_stmt7 = null;
                    {
                        int __temp_odecl2 = this.i.readUInt16();
                        int __temp_odecl3 = this.i.readByte();
                        __temp_stmt7 = new global::haxe.lang.DynamicObject(new int[] { 701242674, 755457067, 1743811007 }, new object[] { disposalMethod, (((packed & 1)) == 1), (((packed & 2)) == 2) }, new int[] { 772773472, 1462163331 }, new double[] { ((double)(__temp_odecl3)), ((double)(__temp_odecl2)) });
                    }

                    global::format.gif.Extension __temp_stmt6 = global::format.gif.Extension.EGraphicControl(__temp_stmt7);
                    global::format.gif.Block     b            = global::format.gif.Block.BExtension(__temp_stmt6);
                    this.i.readByte();
                    return(b);
                }


                case 254:
                {
                    global::haxe.io.BytesOutput buffer1 = new global::haxe.io.BytesOutput();
                    global::haxe.io.Bytes       bytes1  = global::haxe.io.Bytes.alloc(255);
                    int len1 = this.i.readByte();
                    while ((len1 != 0))
                    {
                        this.i.readBytes(bytes1, 0, len1);
                        buffer1.writeBytes(bytes1, 0, len1);
                        len1 = this.i.readByte();
                    }

                    buffer1.flush();
                    bytes1 = buffer1.getBytes();
                    buffer1.close();
                    return(global::format.gif.Block.BExtension(global::format.gif.Extension.EComment(bytes1.toString())));
                }


                case 255:
                {
                    return(this.readApplicationExtension());
                }


                default:
                {
                    global::haxe.io.BytesOutput buffer2 = new global::haxe.io.BytesOutput();
                    global::haxe.io.Bytes       bytes2  = global::haxe.io.Bytes.alloc(255);
                    int len2 = this.i.readByte();
                    while ((len2 != 0))
                    {
                        this.i.readBytes(bytes2, 0, len2);
                        buffer2.writeBytes(bytes2, 0, len2);
                        len2 = this.i.readByte();
                    }

                    buffer2.flush();
                    bytes2 = buffer2.getBytes();
                    buffer2.close();
                    return(global::format.gif.Block.BExtension(global::format.gif.Extension.EUnknown(subId, bytes2)));
                }
                }
            }
        }
示例#2
0
文件: Data.cs 项目: Yanrishatum/UGif
 public Block_BExtension(global::format.gif.Extension extension) : base(1)
 {
     this.extension = extension;
 }
示例#3
0
文件: Tools.cs 项目: Yanrishatum/UGif
        public static global::haxe.io.Bytes extractFullRGBA(object data, int frameIndex)
        {
            unchecked {
                object gce                  = null;
                int    frameCaret           = 0;
                global::haxe.io.Bytes bytes = global::haxe.io.Bytes.alloc(((((int)(global::haxe.lang.Runtime.getField_f(global::haxe.lang.Runtime.getField(data, "logicalScreenDescriptor", 2032764644, true), "width", 1247983110, true))) * ((int)(global::haxe.lang.Runtime.getField_f(global::haxe.lang.Runtime.getField(data, "logicalScreenDescriptor", 2032764644, true), "height", 38537191, true)))) * 4));
                {
                    global::haxe.ds._List.ListNode <object> _g_head = ((global::haxe.ds.List <object>)(global::haxe.ds.List <object> .__hx_cast <object>(((global::haxe.ds.List)(global::haxe.lang.Runtime.getField(data, "blocks", 669658758, true)))))).h;
                    while ((_g_head != null))
                    {
                        global::format.gif.Block val = ((global::format.gif.Block)(_g_head.item));
                        _g_head = _g_head.next;
                        global::format.gif.Block block = ((global::format.gif.Block)(val));
                        switch (block._hx_index)
                        {
                        case 0:
                        {
                            object frame = (block as global::format.gif.Block_BFrame).frame;
                            {
                                global::haxe.io.Bytes ct = ((global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(frame, "localColorTable", 706588918, true))) ? (((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(frame, "colorTable", 793759659, true)))) : (((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(data, "globalColorTable", 146652910, true)))));
                                if ((ct == null))
                                {
                                    throw global::haxe.lang.HaxeException.wrap("Frame does not have a color table!");
                                }

                                int transparentIndex         = (((((bool)((gce != null))) && global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(gce, "hasTransparentColor", 755457067, true)))) ? ((((int)(global::haxe.lang.Runtime.getField_f(gce, "transparentIndex", 772773472, true))) * ((int)(3)))) : (-1));
                                global::haxe.io.Bytes pixels = ((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(frame, "pixels", 212463405, true)));
                                int x          = 0;
                                int writeCaret = ((((((int)(global::haxe.lang.Runtime.getField_f(frame, "y", 121, true))) * ((int)(global::haxe.lang.Runtime.getField_f(global::haxe.lang.Runtime.getField(data, "logicalScreenDescriptor", 2032764644, true), "width", 1247983110, true)))) + ((int)(global::haxe.lang.Runtime.getField_f(frame, "x", 120, true))))) * 4);
                                int lineSkip   = ((((((int)(global::haxe.lang.Runtime.getField_f(global::haxe.lang.Runtime.getField(data, "logicalScreenDescriptor", 2032764644, true), "width", 1247983110, true))) - ((int)(global::haxe.lang.Runtime.getField_f(frame, "width", 1247983110, true))))) * 4) + 4);
                                global::format.gif.DisposalMethod disposalMethod = ((((frameCaret != frameIndex) && (gce != null))) ? (((global::format.gif.DisposalMethod)(global::haxe.lang.Runtime.getField(gce, "disposalMethod", 701242674, true)))) : (global::format.gif.DisposalMethod.NO_ACTION));
                                switch (disposalMethod._hx_index)
                                {
                                case 2:
                                {
                                    int _g1 = 0;
                                    int _g  = pixels.length;
                                    while ((_g1 < _g))
                                    {
                                        int i = _g1++;
                                        bytes.b[writeCaret]       = ((byte)(0));
                                        bytes.b[(writeCaret + 1)] = ((byte)(0));
                                        bytes.b[(writeCaret + 2)] = ((byte)(0));
                                        bytes.b[(writeCaret + 3)] = ((byte)(0));
                                        if ((++x == ((int)(global::haxe.lang.Runtime.getField_f(frame, "width", 1247983110, true)))))
                                        {
                                            x           = 0;
                                            writeCaret += lineSkip;
                                        }
                                        else
                                        {
                                            writeCaret += 4;
                                        }
                                    }

                                    break;
                                }


                                case 3:
                                {
                                    break;
                                }


                                default:
                                {
                                    int _g11 = 0;
                                    int _g2  = pixels.length;
                                    while ((_g11 < _g2))
                                    {
                                        int i1    = _g11++;
                                        int index = (((int)(pixels.b[i1])) * 3);
                                        if ((transparentIndex != index))
                                        {
                                            bytes.b[writeCaret]       = ((byte)(((int)(ct.b[index]))));
                                            bytes.b[(writeCaret + 1)] = ((byte)(((int)(ct.b[(index + 1)]))));
                                            bytes.b[(writeCaret + 2)] = ((byte)(((int)(ct.b[(index + 2)]))));
                                            bytes.b[(writeCaret + 3)] = ((byte)(255));
                                        }

                                        if ((++x == ((int)(global::haxe.lang.Runtime.getField_f(frame, "width", 1247983110, true)))))
                                        {
                                            x           = 0;
                                            writeCaret += lineSkip;
                                        }
                                        else
                                        {
                                            writeCaret += 4;
                                        }
                                    }

                                    break;
                                }
                                }

                                if ((frameCaret == frameIndex))
                                {
                                    return(bytes);
                                }

                                ++frameCaret;
                                gce = null;
                            }

                            break;
                        }


                        case 1:
                        {
                            global::format.gif.Extension ext = (block as global::format.gif.Block_BExtension).extension;
                            if ((ext._hx_index == 0))
                            {
                                object g = (ext as global::format.gif.Extension_EGraphicControl).gce;
                                gce = g;
                            }

                            break;
                        }


                        default:
                        {
                            break;
                        }
                        }
                    }
                }

                return(bytes);
            }
        }
示例#4
0
文件: Data.cs 项目: Yanrishatum/UGif
 public static global::format.gif.Block BExtension(global::format.gif.Extension extension)
 {
     return(new global::format.gif.Block_BExtension(extension));
 }
示例#5
0
文件: Tools.cs 项目: Yanrishatum/UGif
        public static global::haxe.io.Bytes extractRGBA(object data, int frameIndex)
        {
            unchecked {
                object gce        = null;
                int    frameCaret = 0;
                {
                    global::haxe.ds._List.ListNode <object> _g_head = ((global::haxe.ds.List <object>)(global::haxe.ds.List <object> .__hx_cast <object>(((global::haxe.ds.List)(global::haxe.lang.Runtime.getField(data, "blocks", 669658758, true)))))).h;
                    while ((_g_head != null))
                    {
                        global::format.gif.Block val = ((global::format.gif.Block)(_g_head.item));
                        _g_head = _g_head.next;
                        global::format.gif.Block block = ((global::format.gif.Block)(val));
                        switch (block._hx_index)
                        {
                        case 0:
                        {
                            object frame = (block as global::format.gif.Block_BFrame).frame;
                            {
                                if ((frameCaret == frameIndex))
                                {
                                    global::haxe.io.Bytes bytes = global::haxe.io.Bytes.alloc(((((int)(global::haxe.lang.Runtime.getField_f(frame, "width", 1247983110, true))) * ((int)(global::haxe.lang.Runtime.getField_f(frame, "height", 38537191, true)))) * 4));
                                    global::haxe.io.Bytes ct    = ((global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(frame, "localColorTable", 706588918, true))) ? (((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(frame, "colorTable", 793759659, true)))) : (((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(data, "globalColorTable", 146652910, true)))));
                                    if ((ct == null))
                                    {
                                        throw global::haxe.lang.HaxeException.wrap("Frame does not have a color table!");
                                    }

                                    int transparentIndex = (((((bool)((gce != null))) && global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(gce, "hasTransparentColor", 755457067, true)))) ? ((((int)(global::haxe.lang.Runtime.getField_f(gce, "transparentIndex", 772773472, true))) * ((int)(3)))) : (-1));
                                    int writeCaret       = 0;
                                    {
                                        int _g1 = 0;
                                        int _g  = ((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(frame, "pixels", 212463405, true))).length;
                                        while ((_g1 < _g))
                                        {
                                            int i     = _g1++;
                                            int index = (((int)(((global::haxe.io.Bytes)(global::haxe.lang.Runtime.getField(frame, "pixels", 212463405, true))).b[i])) * 3);
                                            bytes.b[writeCaret]       = ((byte)(((int)(ct.b[index]))));
                                            bytes.b[(writeCaret + 1)] = ((byte)(((int)(ct.b[(index + 1)]))));
                                            bytes.b[(writeCaret + 2)] = ((byte)(((int)(ct.b[(index + 2)]))));
                                            if ((transparentIndex == index))
                                            {
                                                bytes.b[(writeCaret + 3)] = ((byte)(0));
                                            }
                                            else
                                            {
                                                bytes.b[(writeCaret + 3)] = ((byte)(255));
                                            }

                                            writeCaret += 4;
                                        }
                                    }

                                    return(bytes);
                                }

                                ++frameCaret;
                                gce = null;
                            }

                            break;
                        }


                        case 1:
                        {
                            global::format.gif.Extension ext = (block as global::format.gif.Block_BExtension).extension;
                            if ((ext._hx_index == 0))
                            {
                                object g = (ext as global::format.gif.Extension_EGraphicControl).gce;
                                gce = g;
                            }

                            break;
                        }


                        default:
                        {
                            break;
                        }
                        }
                    }
                }

                return(null);
            }
        }