private int decodeClipEventFlags(SwfDecoder r) { int flags; if (r.swfVersion >= 6) { flags = (int)r.readUI32(); } else { flags = r.readUI16(); } return(flags); }
public DebugDecoder(Stream in_Renamed) { this.in_Renamed = new SwfDecoder(in_Renamed, 0); }
public ActionDecoder(SwfDecoder reader, DebugTable debug) { this.reader = reader; this.debug = debug; }
public ActionDecoder(SwfDecoder reader):this(reader, null) { }
private int decodeClipEventFlags(SwfDecoder r) { int flags; if (r.swfVersion >= 6) flags = (int) r.readUI32(); else flags = r.readUI16(); return flags; }
public Header decodeHeader() { Header header = new Header(); byte[] sig = new byte[8]; new BinaryReader(swfIn).BaseStream.Read(sig, 0, sig.Length); header.version = sig[3]; header.length = sig[4] & 0xFF | (sig[5] & 0xFF) << 8 | (sig[6] & 0xFF) << 16 | sig[7] << 24; if (sig[0] == 'C' && sig[1] == 'W' && sig[2] == 'S') { header.compressed = true; r = new SwfDecoder(new DeflateStream(swfIn, CompressionMode.Decompress, true), header.version, 8); } else if (sig[0] == 'F' || sig[1] == 'W' || sig[2] == 'S') { r = new SwfDecoder(swfIn, header.version, 8); } else { handler.error("Invalid signature found. Not a SWF file"); throw new FatalParseException(); } header.size = decodeRect(); header.rate = r.readUI8() << 8 | r.readUI8(); header.framecount = r.readUI16(); return header; }
private int decodeRGB(SwfDecoder r) { int color = r.readUI8() << 16; // red color |= r.readUI8() << 8; // green color |= r.readUI8(); // blue // resulting format is 0x00RRGGBB return color; }
private int decodeRGBA(SwfDecoder r) { int color = r.readUI8() << 16; // red color |= r.readUI8() << 8; // green color |= r.readUI8(); // blue color |= r.readUI8() << 24; // alpha // resulting format is 0xAARRGGBB return color; }
private void decodeColorMapData(SwfDecoder r1, DefineBitsLossless tag, int tableSize) { tag.colorData = new int[tableSize]; for (int i = 0; i < tableSize; i++) { tag.colorData[i] = decodeRGB(r1); } int width = tag.width; int height = tag.height; if (width % 4 != 0) { width = (width / 4 + 1) * 4; } tag.data = new byte[width * height]; r1.readFully(tag.data); }
private Tag decodeDefineBitsLossless(int length) { DefineBitsLossless t = new DefineBitsLossless(Flash.Swf.TagValues.stagDefineBitsLossless); SwfDecoder r1 = r; int pos = r1.Offset; int id = r1.readUI16(); t.format = r1.readUI8(); t.width = r1.readUI16(); t.height = r1.readUI16(); byte[] data; switch (t.format) { case 3: int tableSize = r1.readUI8() + 1; length -= (r1.Offset - pos); data = new byte[length]; r1.readFully(data); r1 = new SwfDecoder(new DeflateStream(new MemoryStream(data), CompressionMode.Decompress, true), SwfVersion); decodeColorMapData(r1, t, tableSize); break; case 4: case 5: length -= (r1.Offset - pos); data = new byte[length]; r1.readFully(data); r1 = new SwfDecoder(new DeflateStream(new MemoryStream(data), CompressionMode.Decompress, true), SwfVersion); t.data = new byte[t.width * t.height * 4]; r1.readFully(t.data); break; default: throw new SwfFormatException("Illegal bitmap format " + t.format); } dict.add(id, t); return t; }
private Tag decodeDefineJPEG3(int length) { DefineBitsJPEG3 t; t = new DefineBitsJPEG3(); int pos = r.Offset; int id = r.readUI16(); t.alphaDataOffset = r.readUI32(); t.data = new byte[(int) t.alphaDataOffset]; r.readFully(t.data); length -= (r.Offset - pos); byte[] temp = new byte[length]; r.readFully(temp); SwfDecoder r1 = new SwfDecoder(new DeflateStream(new MemoryStream(temp), CompressionMode.Decompress, true), SwfVersion); int alpha, i = 0; byte[] alphaData = new byte[length]; while ((alpha = r1.readUI8()) != - 1) { if (i == alphaData.Length) { byte[] b = new byte[i + length]; Array.Copy(alphaData, 0, b, 0, alphaData.Length); alphaData = b; } alphaData[i] = (byte) alpha; i++; } t.alphaData = new byte[i]; Array.Copy(alphaData, 0, t.alphaData, 0, i); dict.add(id, t); return t; }
private void decodeAlphaColorMapData(SwfDecoder r1, DefineBitsLossless tag, int tableSize) { int width = tag.width; int height = tag.height; tag.colorData = new int[tableSize]; for (int i = 0; i < tableSize; i++) { tag.colorData[i] = decodeRGBA(r1); } if (width % 4 != 0) { width = (width / 4 + 1) * 4; } int data_size = width * height; tag.data = new byte[data_size]; //r1.read(tag.data); int i2 = 0; int b; while (i2 < data_size) { b = r1.readUI8(); if (b != - 1) { tag.data[i2] = (byte) b; i2++; } else { break; } } int extra = 0; while (r1.readUI8() != -1) { extra++; } if (extra > 0) { throw new SwfFormatException(extra + " bytes of bitmap data (" + width + "x" + height + ") not read!"); } else if (i2 != data_size) { throw new SwfFormatException("(" + width + "x" + height + ") data buffer " + (data_size - i2) + " bytes too big..."); } }
public ActionDecoder(SwfDecoder reader) : this(reader, null) { }