public static int loopCount(object data) { unchecked { { 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)); if ((block._hx_index == 1)) { if (((block as global::format.gif.Block_BExtension).extension._hx_index == 3)) { if ((((block as global::format.gif.Block_BExtension).extension as global::format.gif.Extension_EApplicationExtension).ext._hx_index == 0)) { int loops = (((block as global::format.gif.Block_BExtension).extension as global::format.gif.Extension_EApplicationExtension).ext as global::format.gif.ApplicationExtension_AENetscapeLooping).loops; return(loops); } } } } } return(1); } }
public static object frame(object data, int frameIndex) { int counter = 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)); if ((block._hx_index == 0)) { object frame = (block as global::format.gif.Block_BFrame).frame; { if ((counter == frameIndex)) { return(frame); } ++counter; } } } } return(null); }
public static object graphicControl(object data, int frameIndex) { unchecked { int counter = 0; object gce = null; { 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 ((counter == frameIndex)) { return(gce); } gce = null; ++counter; } break; } case 1: { if (((block as global::format.gif.Block_BExtension).extension._hx_index == 0)) { object g = ((block as global::format.gif.Block_BExtension).extension as global::format.gif.Extension_EGraphicControl).gce; gce = g; } break; } default: { break; } } } } return(null); } }
public static int framesCount(object data) { int frames = 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)); if ((block._hx_index == 0)) { ++frames; } } } return(frames); }
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))); } } } }
public virtual object read() { unchecked { { int _g = 0; global::haxe.root.Array <int> _g1 = new global::haxe.root.Array <int>(new int[] { 71, 73, 70 }); while ((_g < _g1.length)) { int b = _g1[_g]; ++_g; if ((this.i.readByte() != b)) { throw global::haxe.lang.HaxeException.wrap("Invalid header"); } } } string gifVer = this.i.readString(3); global::format.gif.Version version = global::format.gif.Version.GIF89a; switch (gifVer) { case "87a": { version = global::format.gif.Version.GIF87a; break; } case "89a": { version = global::format.gif.Version.GIF89a; break; } default: { version = global::format.gif.Version.Unknown(gifVer); break; } } int width = this.i.readUInt16(); int height = this.i.readUInt16(); int packedField = this.i.readByte(); int bgIndex = this.i.readByte(); double pixelAspectRatio = ((double)(this.i.readByte())); if ((pixelAspectRatio != 0)) { pixelAspectRatio = (((pixelAspectRatio + 15)) / 64); } else { pixelAspectRatio = ((double)(1)); } object lsd = new global::haxe.lang.DynamicObject(new int[] { 808948541, 2070785640 }, new object[] { (((packedField & 8)) == 8), (((packedField & 128)) == 128) }, new int[] { 38537191, 234855119, 623891245, 736935997, 1018258543, 1247983110 }, new double[] { ((double)(height)), ((double)((2 << ((packedField & 7))))), pixelAspectRatio, ((double)(bgIndex)), ((double)(((int)((((uint)(((packedField & 112)))) >> 4))))), ((double)(width)) }); global::haxe.io.Bytes gct = null; if (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(lsd, "hasGlobalColorTable", 2070785640, true))) { gct = this.readColorTable(((int)(global::haxe.lang.Runtime.getField_f(lsd, "globalColorTableSize", 234855119, true)))); } global::haxe.ds.List <object> blocks = new global::haxe.ds.List <object>(); while (true) { global::format.gif.Block b1 = this.readBlock(); blocks.@add(b1); if ((b1 == global::format.gif.Block.BEOF)) { break; } } return(new global::haxe.lang.DynamicObject(new int[] { 146652910, 669658758, 2032764644, 2096228120 }, new object[] { gct, blocks, lsd, version }, new int[] {}, new double[] {})); } }
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); } }
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); } }