public static global::haxe.ds.List <object> build32BGRA(int width, int height, global::haxe.io.Bytes data, global::haxe.lang.Null <int> level) { unchecked { global::haxe.lang.Null <int> level1 = ((!(level.hasValue)) ? (new global::haxe.lang.Null <int>(9, true)) : (level)); global::haxe.io.Bytes rgba = global::haxe.io.Bytes.alloc((((width * height) * 4) + height)); int w = 0; int r = 0; { int _g1 = 0; int _g = height; while ((_g1 < _g)) { int y = _g1++; rgba.b[w++] = ((byte)(0)); { int _g3 = 0; int _g2 = width; while ((_g3 < _g2)) { int x = _g3++; rgba.b[w++] = ((byte)(((int)(data.b[(r + 2)])))); rgba.b[w++] = ((byte)(((int)(data.b[(r + 1)])))); rgba.b[w++] = ((byte)(((int)(data.b[r])))); rgba.b[w++] = ((byte)(((int)(data.b[(r + 3)])))); r += 4; } } } } global::haxe.ds.List <object> l = new global::haxe.ds.List <object>(); object __temp_stmt2 = null; { global::format.png.Color __temp_odecl1 = global::format.png.Color.ColTrue(true); __temp_stmt2 = new global::haxe.lang.DynamicObject(new int[] { 1247572323, 1501088657 }, new object[] { __temp_odecl1, false }, new int[] { 38537191, 1247983110, 1724357446 }, new double[] { ((double)(height)), ((double)(width)), ((double)(8)) }); } l.@add(global::format.png.Chunk.CHeader(__temp_stmt2)); l.@add(global::format.png.Chunk.CData(global::format.tools.Deflate.run(rgba, level1))); l.@add(global::format.png.Chunk.CEnd); return(l); } }
public virtual void write(global::haxe.ds.List <object> png) { unchecked { { int _g = 0; global::haxe.root.Array <int> _g1 = new global::haxe.root.Array <int>(new int[] { 137, 80, 78, 71, 13, 10, 26, 10 }); while ((_g < _g1.length)) { int b = _g1[_g]; ++_g; this.o.writeByte(b); } } { global::haxe.ds._List.ListNode <object> _g_head = png.h; while ((_g_head != null)) { global::format.png.Chunk val = ((global::format.png.Chunk)(_g_head.item)); _g_head = _g_head.next; global::format.png.Chunk c = ((global::format.png.Chunk)(val)); switch (c._hx_index) { case 0: { this.writeChunk("IEND", global::haxe.io.Bytes.alloc(0)); break; } case 1: { object h = (c as global::format.png.Chunk_CHeader).h; { global::haxe.io.BytesOutput b1 = new global::haxe.io.BytesOutput(); b1.set_bigEndian(true); b1.writeInt32(((int)(global::haxe.lang.Runtime.getField_f(h, "width", 1247983110, true)))); b1.writeInt32(((int)(global::haxe.lang.Runtime.getField_f(h, "height", 38537191, true)))); b1.writeByte(((int)(global::haxe.lang.Runtime.getField_f(h, "colbits", 1724357446, true)))); global::format.png.Color _g2 = ((global::format.png.Color)(global::haxe.lang.Runtime.getField(h, "color", 1247572323, true))); int tmp = default(int); switch (_g2._hx_index) { case 0: { bool alpha = (_g2 as global::format.png.Color_ColGrey).alpha; tmp = ((alpha) ? (4) : (0)); break; } case 1: { bool alpha1 = (_g2 as global::format.png.Color_ColTrue).alpha; tmp = ((alpha1) ? (6) : (2)); break; } case 2: { tmp = 3; break; } } b1.writeByte(tmp); b1.writeByte(0); b1.writeByte(0); b1.writeByte(((global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.getField(h, "interlaced", 1501088657, true))) ? (1) : (0))); this.writeChunk("IHDR", b1.getBytes()); } break; } case 2: { global::haxe.io.Bytes d = (c as global::format.png.Chunk_CData).b; this.writeChunk("IDAT", d); break; } case 3: { global::haxe.io.Bytes b2 = (c as global::format.png.Chunk_CPalette).b; this.writeChunk("PLTE", b2); break; } case 4: { global::haxe.io.Bytes data = (c as global::format.png.Chunk_CUnknown).data; string id = (c as global::format.png.Chunk_CUnknown).id; this.writeChunk(id, data); break; } } } } } }