public DefineShape3Tag(SwfReader r) { this.ShapeId = r.GetUI16(); this.ShapeBounds = new Rect(r); this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape3); r.Align(); }
public LineStyle2(SwfReader r, ShapeType shapeType) { this.Width = r.GetUI16(); this.StartCapStyle = (CapStyle)r.GetBits(2); this.JoinStyle = (JoinStyle)r.GetBits(2); this.HasFillFlag = r.GetBit(); this.NoHScaleFlag = r.GetBit(); this.NoVScaleFlag = r.GetBit(); this.PixelHintingFlag = r.GetBit(); r.GetBits(5); // skip this.NoClose = r.GetBit(); this.EndCapStyle = (CapStyle)r.GetBits(2); if (this.JoinStyle == JoinStyle.MiterJoin) { this.MiterLimitFactor = (float)((r.GetByte() / 0x100) + r.GetByte()); } if (this.HasFillFlag) { this.FillStyle = FillStyleArray.ParseFillStyle2(r, shapeType); } else { this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); } }
public static VexTree ProcessFile(string fileName) { VexTree v2tree = null; if (File.Exists(fileName)) { fileName = Path.GetFullPath(fileName); Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName)); FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string name = Path.GetFileNameWithoutExtension(fileName); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); SwfCompilationUnit scu = new SwfCompilationUnit(r, name); if (scu.IsValid) { v2tree = ProcessSwf(scu); //SwfToV2DContent(scu, null); Console.WriteLine(""); } else { Console.WriteLine("Not a valid swf file: " + fileName); Console.WriteLine("Usage: v2d <filename>"); } } else { Console.WriteLine(fileName + " does not exist."); Console.WriteLine("Usage: v2d <filename>"); } return v2tree; }
public DefineSoundTag(SwfReader r, uint tagLen) { SoundId = r.GetUI16(); SoundFormat = (SoundCompressionType)r.GetBits(4); uint sr = r.GetBits(2); switch (sr) { case 0: SoundRate = 5512; // ? break; case 1: SoundRate = 11025; break; case 2: SoundRate = 22050; break; case 3: SoundRate = 44100; break; } SoundSize = r.GetBit() ? 16U : 8U; IsStereo = r.GetBit(); r.Align(); SoundSampleCount = r.GetUI32(); // todo: this needs to decompress if mp3 etc SoundData = r.GetBytes(tagLen - 7); }
//public static GdiForm gf; static void Main(string[] args) { string fileName = "test14.swf"; if (args.Length > 0) { fileName = args[0]; } FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); SwfCompilationUnit scu = new SwfCompilationUnit(r); //StringWriter sw = new StringWriter(); //IndentedTextWriter w = new IndentedTextWriter(sw); //scu.Dump(w); //Debug.WriteLine(sw.ToString()); SwfToVex s2v = new SwfToVex(); VexObject v = s2v.Convert(scu); XamlRenderer xr = new WPFRenderer(); xr.GenerateXaml(v); //GdiRenderer gr = new GdiRenderer(); //List<Bitmap> bmps = gr.GenerateBitmaps(v); ////gr.ExportBitmaps(bmps); //gf = new GdiForm(bmps); //Application.EnableVisualStyles(); //Application.Run(gf); }
public FilterGradientGlow(SwfReader r) { NumColors = (uint)r.GetByte(); GradientColors = new RGBA[NumColors]; for (int i = 0; i < NumColors; i++) { GradientColors[i] = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); } GradientRatio = new uint[NumColors]; for (int i = 0; i < NumColors; i++) { GradientRatio[i] = (uint)r.GetByte(); } BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Angle = r.GetFixed16_16(); Distance = r.GetFixed16_16(); Strength = r.GetFixed8_8(); InnerShadow = r.GetBit(); Knockout = r.GetBit(); CompositeSource = r.GetBit(); OnTop = r.GetBit(); Passes = r.GetBits(4); r.Align(); }
public StraightEdgeRecord(SwfReader r) { this.DeltaX = 0; this.DeltaY = 0; uint nbits = r.GetBits(4) + 2; bool isGeneralLine = r.GetBit(); // not vertical or horizontal if (isGeneralLine) { DeltaX = r.GetSignedNBits(nbits); DeltaY = r.GetSignedNBits(nbits); } else { bool isHorz = r.GetBit(); if (isHorz) { DeltaY = r.GetSignedNBits(nbits); } else { DeltaX = r.GetSignedNBits(nbits); } } }
public static string Convert(string fileName, out SwfCompilationUnit scu, out VexObject v) { v = null; string result = "Failed to convert."; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string name = Path.GetFileNameWithoutExtension(fileName); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); scu = new SwfCompilationUnit(r, name); if (scu.IsValid) { result = "\n\n**** Converting to SwfCompilationUnit ****\n"; #if DEBUG StringWriter sw = new StringWriter(); IndentedTextWriter w = new IndentedTextWriter(sw); scu.Dump(w); Debug.WriteLine(sw.ToString()); #endif result += scu.Log.ToString(); SwfToVex s2v = new SwfToVex(); v = s2v.Convert(scu); result += "\n\n**** Converting to Vex ****\n"; result += s2v.Log.ToString(); } return result; }
public FilterBlur(SwfReader r) { BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Passes = r.GetBits(5); r.GetBits(3); // reserved r.Align(); }
public FilterColorMatrix(SwfReader r) { this.Matrix = new float[20]; for (int i = 0; i < 20; i++) { this.Matrix[i] = r.GetFloat32(); } }
public bool TargetIsSprite; // or sprite #endregion Fields #region Constructors public GetURL2(SwfReader r) { SendVarsMethod = (SendVarsMethod)r.GetBits(2); r.GetBits(4); // reserved TargetIsSprite = r.GetBit(); LoadVariables = r.GetBit(); r.Align(); }
// only used for glyphs public Shape(SwfReader r) { r.Align(); fillBits = r.GetBits(4); // always one lineBits = r.GetBits(4); // always zero ParseShapeRecords(r); }
public Rect(SwfReader r) { byte minBits = (byte)r.GetBits(5); XMin = r.GetSignedNBits(minBits); XMax = r.GetSignedNBits(minBits); YMin = r.GetSignedNBits(minBits); YMax = r.GetSignedNBits(minBits); r.Align(); }
public CurvedEdgeRecord(SwfReader r) { uint nbits = r.GetBits(4) + 2; this.ControlX = r.GetSignedNBits(nbits); this.ControlY = r.GetSignedNBits(nbits); this.AnchorX = r.GetSignedNBits(nbits); this.AnchorY = r.GetSignedNBits(nbits); }
public ExportAssetsTag(SwfReader r) { uint count = r.GetUI16(); for (int i = 0; i < count; i++) { uint index = r.GetUI16(); string name = r.GetString(); Exports.Add(index, name); } }
public ConstantPool(SwfReader r) { uint len = r.GetUI16(); Constants = new string[len]; for (int i = 0; i < len; i++) { Constants[i] = r.GetString(); } }
public SolidFill(SwfReader r, bool useAlpha) { if (useAlpha) { this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); } else { this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte()); } }
public DefineFunction2(SwfReader r, ConstantPool cp) { this.cp = cp; FunctionName = r.GetString(); uint paramCount = r.GetUI16(); RegisterCount = (uint)r.GetByte(); Preloads = PreloadFlags.Empty; if (r.GetBit()) { Preloads |= PreloadFlags.Parent; } if (r.GetBit()) { Preloads |= PreloadFlags.Root; } SuppressSuperFlag = r.GetBit(); if (r.GetBit()) { Preloads |= PreloadFlags.Super; } SuppressArgumentsFlag = r.GetBit(); if (r.GetBit()) { Preloads |= PreloadFlags.Arguments; } SuppressThisFlag = r.GetBit(); if (r.GetBit()) { Preloads |= PreloadFlags.This; } r.GetBits(7); // reserved if (r.GetBit()) { Preloads |= PreloadFlags.Global; } for (int i = 0; i < paramCount; i++) { uint reg = r.GetByte(); string name = r.GetString(); Parameters.Add(reg, name); } CodeSize = r.GetUI16(); }
public LineStyle(SwfReader r, bool useAlpha) { this.Width = r.GetUI16(); if (useAlpha) { this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); } else { this.Color = new RGBA(r.GetByte(), r.GetByte(), r.GetByte()); } }
static void Main(string[] args) { Console.WriteLine("SWF BITMAP PACKER - swf v8"); Console.WriteLine(""); string fileName = (args.Length < 1) ? "test.swf" : args[0]; if (File.Exists(fileName)) { fileName = Path.GetFullPath(fileName); Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName)); FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string name = Path.GetFileNameWithoutExtension(fileName); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); SwfCompilationUnit scu = new SwfCompilationUnit(r, name); if (scu.IsValid) { SwfToVex s2v = new SwfToVex(); VexObject vo = s2v.Convert(scu); Dictionary<uint, string> bitmapPaths = s2v.bitmapPaths; Dictionary<uint, System.Drawing.Rectangle> rectResult = new Dictionary<uint, System.Drawing.Rectangle>(); UnsafeBitmap fullBitmap = BitmapPacker.PackBitmaps(bitmapPaths, rectResult); foreach (var rect in rectResult) { Console.WriteLine("\t" + rect.Value + ","); } fullBitmap.Bitmap.Save("fullBitmap.png"); BitmapSwapper bs = new BitmapSwapper(); bs.Convert(scu, fullBitmap, rectResult); MemoryStream ms = new MemoryStream(); SwfWriter swfWriter = new SwfWriter(ms); scu.ToSwf(swfWriter); byte[] swfBytes = swfWriter.ToArray(); FileStream fsw = new FileStream("result.swf", FileMode.Create, FileAccess.Write); fsw.Write(swfBytes, 0, swfBytes.Length); fsw.Close(); ms.Close(); } else { Console.WriteLine("Not a valid swf file: " + fileName); Console.WriteLine("Usage: SwfBitmapPacker <filename>"); } } else { Console.WriteLine(fileName + " does not exist."); Console.WriteLine("Usage: SwfBitmapPacker <filename>"); } }
public PlaceObjectTag(SwfReader r, uint tagEnd) { Character = r.GetUI16(); Depth = r.GetUI16(); Matrix = new Matrix(r); if (tagEnd != r.Position) { HasColorTransform = true; ColorTransform = new ColorTransform(r, false); } }
public SoundStreamBlockTag(SwfReader r, uint tagLen) { SampleCount = r.GetUI16(); SoundData = r.GetBytes(tagLen - 2); // assume mp3 for now //SoundData = new Mp3SoundData[SampleCount]; //for (int i = 0; i < SampleCount; i++) //{ // SoundData[i] = new Mp3SoundData(r); //} }
public DefineShape4Tag(SwfReader r) { this.ShapeId = r.GetUI16(); this.ShapeBounds = new Rect(r); this.EdgeBounds = new Rect(r); r.SkipBits(6); this.UsesNonScalingStrokes = r.GetBit(); this.UsesScalingStrokes = r.GetBit(); this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape4); r.Align(); }
public static string Convert( string fileName, bool isSilverlight, out SwfCompilationUnit scu, out VexObject v, out string xamlFileName) { string result = "Failed to convert."; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string name = Path.GetFileNameWithoutExtension(fileName); SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length)); scu = new SwfCompilationUnit(r, name); if (scu.IsValid) { result = "\n\n**** Converting to SwfCompilationUnit ****\n"; #if DEBUG StringWriter sw = new StringWriter(); IndentedTextWriter w = new IndentedTextWriter(sw); scu.Dump(w); Debug.WriteLine(sw.ToString()); #endif result += scu.Log.ToString(); SwfToVex s2v = new SwfToVex(); v = s2v.Convert(scu); result += "\n\n**** Converting to Vex ****\n"; result += s2v.Log.ToString(); XamlRenderer xr; if (isSilverlight) { xr = new Silverlight10Renderer(); } else { xr = new WPFRenderer(); } xr.GenerateXaml(v, out xamlFileName); result += "\n\n**** Converting to Xaml ****\n"; result += xr.Log.ToString(); result += "\n\nSuccess."; } else { result = "Not a valid swf file: " + fileName; v = null; xamlFileName = ""; } return result; }
public DefineButtonSound(SwfReader r) { ButtonId = r.GetUI16(); ButtonSoundChar0 = r.GetUI16(); ButtonSoundInfo0 = new SoundInfo(r); ButtonSoundChar1 = r.GetUI16(); ButtonSoundInfo1 = new SoundInfo(r); ButtonSoundChar2 = r.GetUI16(); ButtonSoundInfo2 = new SoundInfo(r); ButtonSoundChar3 = r.GetUI16(); ButtonSoundInfo3 = new SoundInfo(r); }
public ZoneRecord(SwfReader r) { NumZoneData = r.GetByte(); AlignmentCoordinate1 = r.GetFixedNBits(16); Range1 = r.GetFixedNBits(16); AlignmentCoordinate2 = r.GetFixedNBits(16); Range2 = r.GetFixedNBits(16); r.GetBits(6); // reserved ZoneMaskX = r.GetBit(); ZoneMaskY = r.GetBit(); r.Align(); }
public FillStyleArray(SwfReader r, ShapeType shapeType) { int fillCount = (int)r.GetByte(); if (fillCount == 0xFF) { fillCount = (int)r.GetUI16(); } for (int i = 0; i < fillCount; i++) { FillStyles.Add(ParseFillStyle2(r, shapeType)); } }
public CSMTextSettingsTag(SwfReader r) { TextId = r.GetUI16(); UseFlashType = r.GetBits(2); GridFit = r.GetBits(3); r.GetBits(3); // reserved r.Align(); Thickness = r.GetFixedNBits(32); Sharpness = r.GetFixedNBits(32); r.GetByte(); // reserved }
public JPEGTables(SwfReader r, uint curTagLen) { if(curTagLen > 8) { r.GetBytes(2); //jpg SOI Marker JpegTable = r.GetBytes(curTagLen - 4); r.GetBytes(2); //jpg EOI Marker } else { JpegTable = new byte[0]; } }
public DefineFunction(SwfReader r, ConstantPool cp) { this.cp = cp; FunctionName = r.GetString(); uint paramCount = r.GetUI16(); Params = new string[paramCount]; for (int i = 0; i < paramCount; i++) { Params[i] = r.GetString(); } CodeSize = r.GetUI16(); }
public DefineBitsLosslessTag(SwfReader r, uint curTagLen, bool hasAlpha) { HasAlpha = hasAlpha; if (hasAlpha) { tagType = TagType.DefineBitsLossless2; } CharacterId = r.GetUI16(); BitmapFormat = (BitmapFormat)r.GetByte(); this.Width = r.GetUI16(); this.Height = r.GetUI16(); if (BitmapFormat == BitmapFormat.Colormapped8Bit) // 8-bit colormapped image { this.ColorCount = (uint)r.GetByte() + 1; this.isIndexedColors = true; uint colorBytes = hasAlpha ? (uint)4 : (uint)3; uint padWidth = this.Width + (4 - (this.Width % 4)); // temp for debugging uint pos = r.Position; OrgBitmapData = r.GetBytes(curTagLen - 8); r.Position = pos; // end temp uint unzippedSize = (this.ColorCount * colorBytes) + (padWidth * this.Height); byte[] mapData = r.Decompress(curTagLen - 8, unzippedSize); uint index = 0; this.ColorTable = new RGBA[this.ColorCount]; for (int i = 0; i < this.ColorCount; i++) { if (hasAlpha) { this.ColorTable[i] = new RGBA(mapData[index], mapData[index + 1], mapData[index + 2], mapData[index + 3]); } else { this.ColorTable[i] = new RGBA(mapData[index], mapData[index + 1], mapData[index + 2]); } index += colorBytes; } this.ColorData = new uint[this.Width * this.Height]; index = 0; int offset = (int)(this.ColorCount * colorBytes); for (int i = 0; i < padWidth * this.Height; i++) { if ((i % padWidth) < this.Width) // exclude padding { this.ColorData[index++] = mapData[i + offset]; } } } else if (BitmapFormat == BitmapFormat.RGB15Bit) // RGBx555 { // todo: find a test file for rgb555 uint colorBytes = 2; uint padWidth = this.Width * colorBytes; padWidth += (4 - padWidth) % 4; // temp for debugging uint pos = r.Position; OrgBitmapData = r.GetBytes(curTagLen - 7); r.Position = pos; // end temp uint unzippedSize = (padWidth * this.Height) * colorBytes; byte[] mapData = r.Decompress(curTagLen - 7, unzippedSize); int index = 0; this.BitmapData = new RGBA[this.Width * this.Height]; for (uint i = 0; i < unzippedSize; i += colorBytes) { if ((i % padWidth) < (this.Width * colorBytes)) // exclude padding { byte b0 = mapData[i]; byte b1 = mapData[i + 1]; byte rd = (byte)((b0 & 0x7C) << 1); byte gr = (byte)(((b0 & 0x03) << 6) | ((b1 & 0xE0) >> 2)); byte bl = (byte)((b1 & 0x1F) << 3); this.BitmapData[index++] = new RGBA(rd, gr, bl); } } } else if (BitmapFormat == BitmapFormat.RGB24Bit) // RGB 24 { // temp for debugging uint pos = r.Position; OrgBitmapData = r.GetBytes(curTagLen - 7); r.Position = pos; // end temp uint colorBytes = 4; // 4 bytes will always be byte aligned uint unzippedSize = (this.Width * this.Height) * colorBytes; byte[] mapData = r.Decompress(curTagLen - 7, unzippedSize); int index = 0; this.BitmapData = new RGBA[this.Width * this.Height]; for (uint i = 0; i < unzippedSize; i += colorBytes) { if (hasAlpha) { this.BitmapData[index++] = new RGBA(mapData[i + 1], mapData[i + 2], mapData[i + 3], mapData[i]); } else { this.BitmapData[index++] = new RGBA(mapData[i + 1], mapData[i + 2], mapData[i + 3]); } } } }
public PlaceObjectTag(SwfReader r) { Character = r.GetUI16(); Depth = r.GetUI16(); Matrix = new Matrix(r); }
public ShowFrame(SwfReader r) { }
public PrimitiveConstant8(SwfReader r) { Constant8Value = (uint)r.GetByte(); }
public UnsupportedDefinitionTag(SwfReader r, string msg) { this.Message = msg; }
public WaitForFrame(SwfReader r) { Frame = r.GetUI16(); SkipCount = (uint)r.GetByte(); }
public Mp3Frame(SwfReader r) { //r.GetBytes(); }
public ActionRecords(SwfReader r, uint tagLen, bool isInitTag) { this.IsInitActions = isInitTag; if (isInitTag) { InitTarget = r.GetUI16(); } CodeSize = tagLen; uint codeEnd = r.Position + tagLen; // clip events dont have an end tag AddScope(this, r); AddLineNumber(r.Position); ActionKind actionCode = (ActionKind)0xFF; bool hitEnd = false; while (r.Position < codeEnd && !hitEnd) //(actionCode != ActionKind.End)) { if (r.Position >= curBounds) { RemoveScope(); } actionCode = (ActionKind)r.GetByte(); uint len = 0; if (((byte)actionCode & 0x80) > 0) { len = r.GetUI16(); } AddLineNumber(r.Position + len); switch (actionCode) { case ActionKind.Add: curStatements.Add(new Add()); break; case ActionKind.Add2: curStatements.Add(new Add2()); break; case ActionKind.And: curStatements.Add(new And()); break; case ActionKind.AsciiToChar: curStatements.Add(new AsciiToChar()); break; case ActionKind.BitAnd: curStatements.Add(new BitAnd()); break; case ActionKind.BitLShift: curStatements.Add(new BitLShift()); break; case ActionKind.BitOr: curStatements.Add(new BitOr()); break; case ActionKind.BitRShift: curStatements.Add(new BitRShift()); break; case ActionKind.BitURShift: curStatements.Add(new BitURShift()); break; case ActionKind.BitXor: curStatements.Add(new BitXor()); break; case ActionKind.Call: curStatements.Add(new Call()); break; case ActionKind.CallFunction: curStatements.Add(new CallFunction()); break; case ActionKind.CallMethod: curStatements.Add(new CallMethod()); break; case ActionKind.CastOp: curStatements.Add(new CastOp()); break; case ActionKind.CharToAscii: curStatements.Add(new CharToAscii()); break; case ActionKind.CloneSprite: curStatements.Add(new CloneSprite()); break; case ActionKind.ConstantPool: ConstantPool cp = new ConstantPool(r); // todo: will need stack for cp CurrentConstantPool = cp; curStatements.Add(cp); break; case ActionKind.Decrement: curStatements.Add(new Decrement()); break; case ActionKind.DefineFunction: DefineFunction df = new DefineFunction(r, CurrentConstantPool); curStatements.Add(df); AddScope(df, r); AddLineLabel((uint)(r.Position + df.CodeSize)); break; case ActionKind.DefineFunction2: DefineFunction2 df2 = new DefineFunction2(r, CurrentConstantPool); curStatements.Add(df2); AddScope(df2, r); AddLineLabel((uint)(r.Position + df2.CodeSize)); break; case ActionKind.DefineLocal: curStatements.Add(new DefineLocal()); break; case ActionKind.DefineLocal2: curStatements.Add(new DefineLocal2()); break; case ActionKind.Delete: curStatements.Add(new Delete()); break; case ActionKind.Delete2: curStatements.Add(new Delete2()); break; case ActionKind.Divide: curStatements.Add(new Divide()); break; case ActionKind.End: curStatements.Add(new End()); hitEnd = true; break; case ActionKind.EndDrag: curStatements.Add(new EndDrag()); break; case ActionKind.Enumerate: curStatements.Add(new Enumerate()); break; case ActionKind.Enumerate2: curStatements.Add(new Enumerate2()); break; case ActionKind.Equals: curStatements.Add(new Equals()); break; case ActionKind.Equals2: curStatements.Add(new Equals2()); break; case ActionKind.Extends: curStatements.Add(new Extends()); break; case ActionKind.GetMember: curStatements.Add(new GetMember()); break; case ActionKind.GetProperty: curStatements.Add(new GetProperty()); break; case ActionKind.GetTime: curStatements.Add(new GetTime()); break; case ActionKind.GetURL: curStatements.Add(new GetURL(r)); break; case ActionKind.GetURL2: curStatements.Add(new GetURL2(r)); break; case ActionKind.GetVariable: curStatements.Add(new GetVariable()); break; case ActionKind.GoToLabel: curStatements.Add(new GoToLabel(r)); break; case ActionKind.GotoFrame: curStatements.Add(new GotoFrame(r)); break; case ActionKind.GotoFrame2: curStatements.Add(new GotoFrame2(r)); break; case ActionKind.Greater: curStatements.Add(new Greater()); break; case ActionKind.If: If ifTag = new If(r); curStatements.Add(ifTag); AddLineLabel((uint)(r.Position + ifTag.BranchOffset)); break; case ActionKind.ImplementsOp: curStatements.Add(new ImplementsOp()); break; case ActionKind.Increment: curStatements.Add(new Increment()); break; case ActionKind.InitArray: curStatements.Add(new InitArray()); break; case ActionKind.InitObject: curStatements.Add(new InitObject()); break; case ActionKind.InstanceOf: curStatements.Add(new InstanceOf()); break; case ActionKind.Jump: Jump jump = new Jump(r); curStatements.Add(jump); AddLineLabel((uint)(r.Position + jump.BranchOffset)); break; case ActionKind.Less: curStatements.Add(new Less()); break; case ActionKind.Less2: curStatements.Add(new Less2()); break; case ActionKind.MBAsciiToChar: curStatements.Add(new MBAsciiToChar()); break; case ActionKind.MBCharToAscii: curStatements.Add(new MBCharToAscii()); break; case ActionKind.MBStringExtract: curStatements.Add(new MBStringExtract()); break; case ActionKind.MBStringLength: curStatements.Add(new MBStringLength()); break; case ActionKind.Modulo: curStatements.Add(new Modulo()); break; case ActionKind.Multiply: curStatements.Add(new Multiply()); break; case ActionKind.NewMethod: curStatements.Add(new NewMethod()); break; case ActionKind.NewObject: curStatements.Add(new NewObject()); break; case ActionKind.NextFrame: curStatements.Add(new NextFrame()); break; case ActionKind.Not: curStatements.Add(new Not()); break; case ActionKind.Or: curStatements.Add(new Or()); break; case ActionKind.Play: curStatements.Add(new Play()); break; case ActionKind.Pop: curStatements.Add(new Pop()); break; case ActionKind.PreviousFrame: curStatements.Add(new PreviousFrame()); break; case ActionKind.Push: curStatements.Add(new Push(r, len + r.Position)); break; case ActionKind.PushDuplicate: curStatements.Add(new PushDuplicate()); break; case ActionKind.RandomNumber: curStatements.Add(new RandomNumber()); break; case ActionKind.RemoveSprite: curStatements.Add(new RemoveSprite()); break; case ActionKind.Return: curStatements.Add(new Return()); break; case ActionKind.SetMember: curStatements.Add(new SetMember()); break; case ActionKind.SetProperty: curStatements.Add(new SetProperty()); break; case ActionKind.SetTarget: curStatements.Add(new SetTarget(r)); break; case ActionKind.SetTarget2: curStatements.Add(new SetTarget2()); break; case ActionKind.SetVariable: curStatements.Add(new SetVariable()); break; case ActionKind.StackSwap: curStatements.Add(new StackSwap()); break; case ActionKind.StartDrag: curStatements.Add(new StartDrag()); break; case ActionKind.Stop: curStatements.Add(new Stop()); break; case ActionKind.StopSounds: curStatements.Add(new StopSounds()); break; case ActionKind.StoreRegister: curStatements.Add(new StoreRegister(r)); break; case ActionKind.StrictEquals: curStatements.Add(new StrictEquals()); break; case ActionKind.StringAdd: curStatements.Add(new StringAdd()); break; case ActionKind.StringEquals: curStatements.Add(new StringEquals()); break; case ActionKind.StringExtract: curStatements.Add(new StringExtract()); break; case ActionKind.StringGreater: curStatements.Add(new StringGreater()); break; case ActionKind.StringLength: curStatements.Add(new StringLength()); break; case ActionKind.StringLess: curStatements.Add(new StringLess()); break; case ActionKind.Subtract: curStatements.Add(new Subtract()); break; case ActionKind.TargetPath: curStatements.Add(new TargetPath()); break; case ActionKind.Throw: // curStatements.Add(new Throw(r)); break; case ActionKind.ToInteger: curStatements.Add(new ToInteger()); break; case ActionKind.ToNumber: curStatements.Add(new ToNumber()); break; case ActionKind.ToString: curStatements.Add(new ToString()); break; case ActionKind.ToggleQuality: curStatements.Add(new ToggleQuality()); break; case ActionKind.Trace: curStatements.Add(new Trace()); break; case ActionKind.Try: // curStatements.Add(new Try(r)); break; case ActionKind.TypeOf: curStatements.Add(new TypeOf()); break; case ActionKind.WaitForFrame: curStatements.Add(new WaitForFrame(r)); break; case ActionKind.WaitForFrame2: curStatements.Add(new WaitForFrame2(r)); break; case ActionKind.With: // curStatements.Add(new With(r)); break; } } GenerateLabels(); }
public ActionRecords(SwfReader r, uint tagLen) : this(r, tagLen, false) { }
public RemoveObject2(SwfReader r) { this.Depth = r.GetUI16(); }
public PrimitiveFloat(SwfReader r) { FloatValue = r.GetFixedNBits(32); }
public DefineButtonCxform(SwfReader r) { ButtonId = r.GetUI16(); ButtonColorTransform = new ColorTransform(r, false); }
private void ParseTags(SwfReader r, byte swfVersion) { bool tagsRemain = true; uint curFrame = 0; while (tagsRemain) { uint b = r.GetUI16(); curTag = (TagType)(b >> 6); curTagLen = b & 0x3F; if (curTagLen == 0x3F) { curTagLen = r.GetUI32(); } uint tagEnd = r.Position + curTagLen; Debug.WriteLine("sprite type: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag)); switch (curTag) { case TagType.End: tagsRemain = false; ControlTags.Add(new EndTag(r)); break; case TagType.PlaceObject: PlaceObjectTag pot = new PlaceObjectTag(r, tagEnd); FirstFrameObjects.Add(pot); ControlTags.Add(pot); break; case TagType.PlaceObject2: PlaceObject2Tag po2t = new PlaceObject2Tag(r, swfVersion); if (po2t.HasCharacter) { FirstFrameObjects.Add(po2t); } ControlTags.Add(po2t); break; case TagType.PlaceObject3: PlaceObject3Tag po3t = new PlaceObject3Tag(r); if (po3t.HasCharacter) { FirstFrameObjects.Add(po3t); } ControlTags.Add(po3t); break; case TagType.RemoveObject: ControlTags.Add(new RemoveObjectTag(r)); break; case TagType.RemoveObject2: ControlTags.Add(new RemoveObject2Tag(r)); break; case TagType.ShowFrame: ControlTags.Add(new ShowFrame(r)); curFrame++; break; case TagType.SoundStreamHead: case TagType.SoundStreamHead2: ControlTags.Add(new SoundStreamHeadTag(r)); break; case TagType.FrameLabel: ControlTags.Add(new FrameLabelTag(r)); break; case TagType.DoAction: ControlTags.Add(new DoActionTag(r, curTagLen)); break; case TagType.DoInitAction: ControlTags.Add(new DoActionTag(r, curTagLen, true)); break; default: // skip if unknown Debug.WriteLine("invalid sprite tag: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag)); r.SkipBytes(curTagLen); break; } if (tagEnd != r.Position) { Console.WriteLine("bad tag in sprite: " + Enum.GetName(typeof(TagType), curTag)); } } }
public GoToLabel(SwfReader r) { Label = r.GetString(); }
public DefineSpriteTag(SwfReader r, byte swfVersion) { this.SpriteId = r.GetUI16(); this.FrameCount = r.GetUI16(); ParseTags(r, swfVersion); }
public GotoFrame(SwfReader r) { Frame = r.GetInt16(); }
public PrimitiveConstant16(SwfReader r) { Constant16Value = r.GetUI16(); }
public StartSoundTag(SwfReader r) { SoundId = r.GetUI16(); SoundInfo = new SoundInfo(r); }
public DefineFontName(SwfReader r) { FontID = r.GetUI16(); FontName = r.GetString(); FontCopyright = r.GetString(); }
public PrimitiveInteger(SwfReader r) { IntegerValue = r.GetInt32(); }
public ClipActions(SwfReader r) : this(r, true) { }
public PrimitiveString(SwfReader r) { StringValue = r.GetString(); }
public PrimitiveBoolean(SwfReader r) { BooleanValue = r.GetByte() > 0 ? true : false; // stored as byte }
public ButtonRecord(SwfReader r, TagType containerTag) { this.containerTag = containerTag; r.GetBits(2); ButtonHasBlendMode = r.GetBit(); ButtonHasFilterList = r.GetBit(); ButtonStateHitTest = r.GetBit(); ButtonStateDown = r.GetBit(); ButtonStateOver = r.GetBit(); ButtonStateUp = r.GetBit(); CharacterID = r.GetUI16(); PlaceDepth = r.GetUI16(); PlaceMatrix = new Matrix(r); if (containerTag == TagType.DefineButton2) { ColorTransform = new ColorTransform(r, true); if (ButtonHasFilterList) { // some dup code from placeObject3 : ( uint filterCount = (uint)r.GetByte(); FilterList = new List <IFilter>(); for (int i = 0; i < filterCount; i++) { FilterKind kind = (FilterKind)r.GetByte(); switch (kind) { case FilterKind.Bevel: FilterList.Add(new FilterBevel(r)); break; case FilterKind.Blur: FilterList.Add(new FilterBlur(r)); break; case FilterKind.ColorMatrix: FilterList.Add(new FilterColorMatrix(r)); break; case FilterKind.Convolution: FilterList.Add(new FilterConvolution(r)); break; case FilterKind.DropShadow: FilterList.Add(new FilterDropShadow(r)); break; case FilterKind.Glow: FilterList.Add(new FilterGlow(r)); break; case FilterKind.GradientBevel: FilterList.Add(new FilterGradientBevel(r)); break; case FilterKind.GradientGlow: FilterList.Add(new FilterGradientGlow(r)); break; default: // unsupported filter break; } } } if (ButtonHasBlendMode) { BlendMode = (BlendMode)r.GetByte(); } } }
public SwfCompilationUnit(SwfReader r) : this(r, "Nameless") { }
//public List<GlyphShape> GlyphShapeTable; public DefineFontTag(SwfReader r) { }