Exemplo n.º 1
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Params.Length);
            for (int i = 0; i < Params.Length; i++)
            {
                w.AppendString(Params[i]);
            }

            w.AppendUI16(CodeSize); // temp
            long startPos = w.Position;

            for (int i = 0; i < Statements.Count; i++)
            {
                Statements[i].ToSwf(w);
            }

            // adjust code size
            long curPos = w.Position;

            if (codeSize != (curPos - startPos))
            {
                codeSize   = (uint)(curPos - startPos);
                w.Position = startPos - 2;
                w.AppendUI16(CodeSize); // acutal
                w.Position = curPos;
            }
        }
Exemplo n.º 2
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            if ((uint)ClipEvents == 0)
            {
                if (isSwf6Plus)
                {
                    w.AppendUI32(0);
                }
                else
                {
                    w.AppendUI16(0);
                }
            }
            else
            {
                w.AppendBits((uint)ClipEvents, 32);

                uint start = (uint)w.Position;
                w.AppendUI32(0);                 // write len after tag written

                if ((ClipEvents & ClipEvents.KeyPress) > 0)
                {
                    w.AppendByte(KeyCode);
                }
                ActionRecords.ToSwf(w);

                uint end = (uint)w.Position;
                w.Position = start;
                w.AppendUI32(end - start - 4);
                w.Position = end;
            }
        }
Exemplo n.º 3
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)PrimitiveType);
            byte b = (BooleanValue == true) ? (byte)0x01 : (byte)0x00;

            w.AppendByte(b);
        }
Exemplo n.º 4
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);
            w.AppendBits((uint)this.StartCapStyle, 2);
            w.AppendBits((uint)this.JoinStyle, 2);
            w.AppendBit(this.HasFillFlag);
            w.AppendBit(this.NoHScaleFlag);
            w.AppendBit(this.NoVScaleFlag);
            w.AppendBit(this.PixelHintingFlag);
            w.AppendBits(0, 5);
            w.AppendBit(this.NoClose);
            w.AppendBits((uint)this.EndCapStyle, 2);

            if (this.JoinStyle == JoinStyle.MiterJoin)
            {
                w.AppendFixed8_8(this.MiterLimitFactor);
            }

            if (this.HasFillFlag)
            {
                this.FillStyle.ToSwf(w);
            }
            else
            {
                w.AppendByte(Color.R);
                w.AppendByte(Color.G);
                w.AppendByte(Color.B);
                if (useAlpha)
                {
                    w.AppendByte(Color.A);
                }
            }
        }
Exemplo n.º 5
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.With);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            // todo: ctor missing
        }
Exemplo n.º 6
0
        public void ToSwf(SwfWriter w)
        {
            if (IsCompressed)
            {
                w.AppendByte((byte)'C');
            }
            else
            {
                w.AppendByte((byte)'F');
            }
            w.AppendByte((byte)'W');
            w.AppendByte((byte)'S');

            w.AppendByte(this.Version);

            w.AppendUI32(this.FileLength);
            this.FrameSize.ToSwf(w);

            ushort frateWhole = (ushort)this.FrameRate;
            uint   frateDec   = (((uint)this.FrameRate * 0x100) & 0xFF);

            w.AppendUI16((uint)((frateWhole << 8) + frateDec));

            w.AppendUI16(this.FrameCount);
        }
Exemplo n.º 7
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBits(0, 4);
            switch (PlaybackSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(PlaybackSoundSize == 16u);
            w.AppendBit(IsStereo);
            w.AppendBits((uint)StreamSoundCompression, 4);

            switch (StreamSoundRate)
            {
            case 55000:
                w.AppendBits(0, 2);
                break;

            case 11000:
                w.AppendBits(1, 2);
                break;

            case 22000:
                w.AppendBits(2, 2);
                break;

            case 44000:
                w.AppendBits(3, 2);
                break;
            }
            w.AppendBit(StreamSoundSize == 16u);
            w.AppendBit(StreamIsStereo);
            w.Align();

            w.AppendUI16(StreamSoundSampleCount);

            if (StreamSoundCompression == SoundCompressionType.MP3)
            {
                w.AppendUI16(LatencySeek);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Exemplo n.º 8
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterID);
            Bounds.ToSwf(w);

            w.AppendBit(HasText);
            w.AppendBit(WordWrap);
            w.AppendBit(Multiline);
            w.AppendBit(Password);
            w.AppendBit(ReadOnly);
            w.AppendBit(HasTextColor);
            w.AppendBit(HasMaxLength);
            w.AppendBit(HasFont);
            w.AppendBit(false);// resreved
            w.AppendBit(AutoSize);
            w.AppendBit(HasLayout);
            w.AppendBit(NoSelect);
            w.AppendBit(Border);
            w.AppendBit(false);// resreved
            w.AppendBit(HTML);
            w.AppendBit(UseOutlines);

            if (HasFont)
            {
                w.AppendUI16(FontID);
                w.AppendUI16(FontHeight);
            }
            if (HasTextColor)
            {
                w.AppendByte((byte)TextColor.R);
                w.AppendByte((byte)TextColor.G);
                w.AppendByte((byte)TextColor.B);
                w.AppendByte((byte)TextColor.A);
            }
            if (HasMaxLength)
            {
                w.AppendUI16(MaxLength);
            }
            if (HasLayout)
            {
                w.AppendByte((byte)Align);
                w.AppendUI16(LeftMargin);
                w.AppendUI16(RightMargin);
                w.AppendUI16(Indent);
                w.AppendUI16((uint)Leading);
            }

            w.AppendString(VariableName);

            if (HasText)
            {
                w.AppendString(InitialText);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 9
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendBit(HasAddTerms);
            w.AppendBit(HasMultTerms);
            uint bits = SwfWriter.MinimumBits(RMultTerm, GMultTerm, BMultTerm, AMultTerm, RAddTerm, GAddTerm, BAddTerm, AAddTerm);

            w.AppendBits(bits, 4);

            if (HasMultTerms)
            {
                w.AppendSignedNBits(RMultTerm, bits);
                w.AppendSignedNBits(GMultTerm, bits);
                w.AppendSignedNBits(BMultTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AMultTerm, bits);
                }
            }
            if (HasAddTerms)
            {
                w.AppendSignedNBits(RAddTerm, bits);
                w.AppendSignedNBits(GAddTerm, bits);
                w.AppendSignedNBits(BAddTerm, bits);
                if (useAlpha)
                {
                    w.AppendSignedNBits(AAddTerm, bits);
                }
            }

            w.Align();
        }
Exemplo n.º 10
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2); // reserved
            w.AppendBit(IsSyncStop);
            w.AppendBit(IsSyncNoMultiple);
            w.AppendBit(HasEnvelope);
            w.AppendBit(HasLoops);
            w.AppendBit(HasOutPoint);
            w.Align();

            if (HasInPoint)
            {
                w.AppendUI32(InPoint);
            }
            if (HasOutPoint)
            {
                w.AppendUI32(OutPoint);
            }
            if (HasLoops)
            {
                w.AppendUI16(LoopCount);
            }
            if (HasEnvelope)
            {
                w.AppendByte((byte)LoopCount);
                uint count = (uint)EnvelopeRecords.Length;
                for (int i = 0; i < EnvelopeRecords.Length; i++)
                {
                    w.AppendUI32(EnvelopeRecords[i].Pos44);
                    w.AppendUI16(EnvelopeRecords[i].LeftLevel);
                    w.AppendUI16(EnvelopeRecords[i].RightLevel);
                }
            }
        }
Exemplo n.º 11
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.If);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendInt16(BranchOffset);
        }
Exemplo n.º 12
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendBits(0, 2);
            w.AppendBit(ButtonHasBlendMode);
            w.AppendBit(ButtonHasFilterList);
            w.AppendBit(ButtonStateHitTest);
            w.AppendBit(ButtonStateDown);
            w.AppendBit(ButtonStateOver);
            w.AppendBit(ButtonStateUp);

            w.AppendUI16(CharacterID);
            w.AppendUI16(PlaceDepth);
            PlaceMatrix.ToSwf(w);

            if (containerTag == TagType.DefineButton2)
            {
                ColorTransform.ToSwf(w, true);

                if (ButtonHasFilterList)
                {
                    w.AppendByte((byte)FilterList.Count);
                    for (int i = 0; i < FilterList.Count; i++)
                    {
                        FilterList[i].ToSwf(w);
                    }
                }
                if (ButtonHasBlendMode)
                {
                    w.AppendByte((byte)BlendMode);
                }
            }
        }
Exemplo n.º 13
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GoToLabel);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(Label);
        }
Exemplo n.º 14
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Jump);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendInt16(BranchOffset);
        }
Exemplo n.º 15
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GoToLabel);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(Label);
        }
Exemplo n.º 16
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
Exemplo n.º 17
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.SetTarget);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(TargetName);
        }
Exemplo n.º 18
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            w.AppendBits(0, 7);
            w.AppendBit(TrackAsMenu);
            w.AppendUI16(ActionOffset); // todo: calc offset

            for (int i = 0; i < Characters.Count; i++)
            {
                Characters[i].ToSwf(w);
            }
            w.AppendByte(0);

            if (ActionOffset > 0)
            {
                ButtonCondActions[ButtonCondActions.Count - 1].CondActionSize = 0;
                for (int i = 0; i < ButtonCondActions.Count; i++)
                {
                    ButtonCondActions[i].ToSwf(w);
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 19
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.WaitForFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendByte((byte)SkipCount);
        }
Exemplo n.º 20
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.WaitForFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendByte((byte)SkipCount);
        }
Exemplo n.º 21
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);

            if (!HasAlphaData)
            {
                if (!HasOwnTable)
                {
                    w.AppendByte(0xFF);
                    w.AppendByte(0xD8);

                    w.AppendBytes(JpegData);

                    w.AppendByte(0xFF);
                    w.AppendByte(0xD9);
                }
                else
                {
                    w.AppendBytes(JpegData);
                }
            }
            else
            {
                w.AppendUI32((uint)JpegData.Length);
                w.AppendBytes(JpegData);

                w.AppendBytes(CompressedAlphaData);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 22
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
Exemplo n.º 23
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            w.AppendBit(true);
            w.AppendBit(true);
            uint bits = SwfWriter.MinimumBits(DeltaX, DeltaY);

            bits = bits < 2 ? 2 : bits; // min 2 bits

            w.AppendBits(bits - 2, 4);
            if (DeltaX != 0 && DeltaY != 0)
            {
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaX, bits);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else if (DeltaX == 0)
            {
                w.AppendBit(false);
                w.AppendBit(true);
                w.AppendSignedNBits(DeltaY, bits);
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(false);
                w.AppendSignedNBits(DeltaX, bits);
            }
        }
Exemplo n.º 24
0
        public void ToSwf(SwfWriter w)
        {
            // write header
            this.Header.ToSwf(w);

            for (int i = 0; i < Tags.Count; i++)
            {
                //if (i == 0x2de)//w.Position >= 0x3cd20)//
                //{
                //    i = i;
                //}
                if (Tags[i] is PlaceObject2Tag)
                {
                    bool is6Plus = this.Header.Version > 5;
                    ((PlaceObject2Tag)Tags[i]).ToSwf(w, is6Plus);
                }
                else
                {
                    Tags[i].ToSwf(w);
                }
            }

            if (Header.IsCompressed)
            {
                w.Zip();
            }

            uint len = (uint)w.Position;
            w.Position = 4;
            w.AppendUI32(len);
            w.Position = len;
        }
Exemplo n.º 25
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.SetTarget);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(TargetName);
        }
Exemplo n.º 26
0
        public void ToSwf(SwfWriter w)
        {
            // write header
            this.Header.ToSwf(w);

            for (int i = 0; i < Tags.Count; i++)
            {
                //if (i == 0x2de)//w.Position >= 0x3cd20)//
                //{
                //    i = i;
                //}
                if (Tags[i] is PlaceObject2Tag)
                {
                    bool is6Plus = this.Header.Version > 5;
                    ((PlaceObject2Tag)Tags[i]).ToSwf(w, is6Plus);
                }
                else
                {
                    Tags[i].ToSwf(w);
                }
            }

            if (Header.IsCompressed)
            {
                w.Zip();
            }

            uint len = (uint)w.Position;

            w.Position = 4;
            w.AppendUI32(len);
            w.Position = len;
        }
Exemplo n.º 27
0
        public void ToSwf(SwfWriter w)
        {
            uint len = 4;

            w.AppendTagIDAndLength(this.TagType, len, false);
            w.AppendUI32(this.flags);
        }
Exemplo n.º 28
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL);
            w.AppendUI16(Length - 3);// don't incude this part

            w.AppendString(UrlString);
            w.AppendString(TargetString);
        }
Exemplo n.º 29
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL);
            w.AppendUI16(Length - 3);// don't incude this part

            w.AppendString(UrlString);
            w.AppendString(TargetString);
        }
Exemplo n.º 30
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendBit(HasClipActions);
            w.AppendBit(HasClipDepth);
            w.AppendBit(HasName);
            w.AppendBit(HasRatio);
            w.AppendBit(HasColorTransform);
            w.AppendBit(HasMatrix);
            w.AppendBit(HasCharacter);
            w.AppendBit(Move);

            w.AppendUI16(Depth);

            if (HasCharacter)
            {
                w.AppendUI16(Character);
            }
            if (HasMatrix)
            {
                Matrix.ToSwf(w);
            }
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, true);
            }
            if (HasRatio)
            {
                w.AppendUI16(Ratio);
            }
            if (HasName)
            {
                w.AppendString(Name);
            }
            if (HasClipDepth)
            {
                w.AppendUI16(ClipDepth);
            }

            if (HasClipActions)
            {
                ClipActions.ToSwf(w, isSwf6Plus);
            }

            //w.ResetLongTagLength(this.TagType, start, true);
            // this may be always long tag?
            if (HasClipActions || HasName)
            {
                w.ResetLongTagLength(this.TagType, start, true); // flash always makes long tags is clip actions are present
            }
            else
            {
                w.ResetLongTagLength(this.TagType, start);
            }
        }
Exemplo n.º 31
0
        public void ToSwf(SwfWriter w)
        {
            uint len = 3;
            w.AppendTagIDAndLength(this.TagType, len, false);

            w.AppendByte(Color.R);
            w.AppendByte(Color.G);
            w.AppendByte(Color.B);
        }
Exemplo n.º 32
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Push);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            for (int i = 0; i < Values.Count; i++)
            {
                Values[i].ToSwf(w);
            }
        }
Exemplo n.º 33
0
        public void ToSwf(SwfWriter w)
        {
            uint len = 3;

            w.AppendTagIDAndLength(this.TagType, len, false);

            w.AppendByte(Color.R);
            w.AppendByte(Color.G);
            w.AppendByte(Color.B);
        }
Exemplo n.º 34
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Exemplo n.º 35
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(ButtonId);
            ButtonColorTransform.ToSwf(w);

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 36
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            w.AppendUI16(0);             // reserved
            w.AppendBits((uint)ClipEvents, 32);

            for (int i = 0; i < ClipActionRecords.Count; i++)
            {
                ClipActionRecords[i].ToSwf(w, isSwf6Plus);
            }
        }
Exemplo n.º 37
0
        public void ToSwf(SwfWriter w, bool isSwf6Plus)
        {
            w.AppendUI16(0); // reserved
            w.AppendBits((uint)ClipEvents, 32);

            for (int i = 0; i < ClipActionRecords.Count; i++)
            {
                ClipActionRecords[i].ToSwf(w, isSwf6Plus);
            }
        }
Exemplo n.º 38
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontID);
            w.AppendString(FontName);
            w.AppendString(FontCopyright);
            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 39
0
        public void ToSwf(SwfWriter w)
        {
            w.Align();
            w.AppendBits(fillBits, 4); // always 1
            w.AppendBits(lineBits, 4); // always 0

            for (int i = 0; i < ShapeRecords.Count; i++)
            {
                ShapeRecords[i].ToSwf(w, ref fillBits, ref lineBits, ShapeType.Glyph);
            }
        }
Exemplo n.º 40
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SampleCount);
            w.AppendBytes(SoundData);

            w.ResetLongTagLength(this.TagType, start);
        }
Exemplo n.º 41
0
 public void ToSwf(SwfWriter w, bool useAlpha)
 {
     w.AppendByte(Ratio);
     w.AppendByte(Color.R);
     w.AppendByte(Color.G);
     w.AppendByte(Color.B);
     if (useAlpha)
     {
         w.AppendByte(Color.A);
     }
 }
Exemplo n.º 42
0
        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>");
            }
        }
Exemplo n.º 43
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendUI16(this.Width);

            w.AppendByte(Color.R);
            w.AppendByte(Color.G);
            w.AppendByte(Color.B);
            if (useAlpha)
            {
                w.AppendByte(Color.A);
            }
        }
Exemplo n.º 44
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true); // rewrite len after tag

            w.AppendUI16(this.ShapeId);
            this.ShapeBounds.ToSwf(w);
            this.Shapes.ToSwf(w, ShapeType.DefineShape3);
            w.Align();

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 45
0
        public void ToSwf(SwfWriter w, bool useAlpha)
        {
            w.AppendByte((byte)this.FillType);

            w.AppendByte(Color.R);
            w.AppendByte(Color.G);
            w.AppendByte(Color.B);
            if (useAlpha)
            {
                w.AppendByte(Color.A);
            }
        }
Exemplo n.º 46
0
 public void ToSwf(SwfWriter w)
 {
     if (!isInitTag)
     {
         w.AppendTagIDAndLength(this.TagType, CodeSize, true);
     }
     else
     {
         w.AppendTagIDAndLength(TagType.DoInitAction, CodeSize, true);
     }
     ActionRecords.ToSwf(w);
 }
Exemplo n.º 47
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16((uint)Exports.Count);
            foreach (uint index in Exports.Keys)
            {
                w.AppendUI16(index);
                w.AppendString(Exports[index]);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 48
0
        public void ToSwf(SwfWriter w)
        {
            w.Align();

            uint bits = SwfWriter.MinimumBits(this.XMax, this.XMin, this.YMax, this.YMin);

            w.AppendBits((uint)bits, 5);
            w.AppendBits((uint)(this.XMin), bits);
            w.AppendBits((uint)(this.XMax), bits);
            w.AppendBits((uint)(this.YMin), bits);
            w.AppendBits((uint)(this.YMax), bits);

            w.Align();
        }
Exemplo n.º 49
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(this.Character);
            w.AppendUI16(this.Depth);
            Matrix.ToSwf(w);
            if (HasColorTransform)
            {
                ColorTransform.ToSwf(w, false);
            }

            w.ResetLongTagLength(this.TagType, start);
        }
Exemplo n.º 50
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)NumZoneData);

            w.AppendFixedNBits(AlignmentCoordinate1, 16);
            w.AppendFixedNBits(Range1, 16);
            w.AppendFixedNBits(AlignmentCoordinate2, 16);
            w.AppendFixedNBits(Range2, 16);

            w.AppendBits(0, 6); // reserved
            w.AppendBit(ZoneMaskX);
            w.AppendBit(ZoneMaskY);

            w.Align();
        }
Exemplo n.º 51
0
        public void ToSwf(SwfWriter w)
        {
            byte[] bytes = BitConverter.GetBytes(DoubleValue);

            w.AppendByte((byte)PrimitiveType);

            w.AppendByte(bytes[4]);
            w.AppendByte(bytes[5]);
            w.AppendByte(bytes[6]);
            w.AppendByte(bytes[7]);

            w.AppendByte(bytes[0]);
            w.AppendByte(bytes[1]);
            w.AppendByte(bytes[2]);
            w.AppendByte(bytes[3]);
        }
Exemplo n.º 52
0
        public void ToSwf(SwfWriter w)
        {
            uint len = 12;
            w.AppendTagIDAndLength(this.TagType, len, false);

            w.AppendUI16(TextId);
            w.AppendBits(UseFlashType, 2);
            w.AppendBits(GridFit, 3);
            w.AppendBits(0, 3); // reserved
            w.Align();

            w.AppendFixedNBits(Thickness, 32);
            w.AppendFixedNBits(Sharpness, 32);

            w.AppendByte(0); // reserved
        }
Exemplo n.º 53
0
        public virtual void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            uint len = (uint)Ids.Length;
            w.AppendUI16(len);

            for (int i = 0; i < len; i++)
            {
                w.AppendUI16(Ids[i]);
                w.AppendString(Names[i]);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 54
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(SpriteId);
            w.AppendUI16(FrameCount);

            for (int i = 0; i < ControlTags.Count; i++)
            {
                ControlTags[i].ToSwf(w);
            }

            // note: Flash always writes this as a long tag.
            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 55
0
        public void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(TextRecordType);
            w.AppendBits(StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }
Exemplo n.º 56
0
        public void ToSwf(SwfWriter w, ShapeType shapeType)
        {
            FillStyles.ToSwf(w, shapeType);
            LineStyles.ToSwf(w, shapeType);

            w.Align();
            uint fillBits = SwfWriter.MinimumBits((uint)FillStyles.FillStyles.Count);
            uint lineBits = SwfWriter.MinimumBits((uint)LineStyles.LineStyles.Count);
            w.AppendBits(fillBits, 4);
            w.AppendBits(lineBits, 4);
            w.Align();

            for (int i = 0; i < ShapeRecords.Count; i++)
            {
                ShapeRecords[i].ToSwf(w, ref fillBits, ref lineBits, shapeType);
            }
        }
Exemplo n.º 57
0
        public void ToSwf(SwfWriter w, ShapeType shapeType)
        {
            if (LineStyles.Count > 0xFE)
            {
                w.AppendByte(0xFF);
                w.AppendUI16((uint)LineStyles.Count);
            }
            else
            {
                w.AppendByte((byte)LineStyles.Count);
            }

            bool useAlpha = shapeType > ShapeType.DefineShape2;
            for (int i = 0; i < LineStyles.Count; i++)
            {
                LineStyles[i].ToSwf(w, useAlpha);
            }
        }
Exemplo n.º 58
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            if(JpegTable.Length > 0)
            {
                    w.AppendByte(0xFF);
                    w.AppendByte(0xD8);

                    w.AppendBytes(JpegTable);

                    w.AppendByte(0xFF);
                    w.AppendByte(0xD9);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 59
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);
            w.AppendBits(CSMTableHint, 2);
            w.AppendBits(0, 6);
            w.Align();

            DefineFont2_3 font = Fonts[FontId];
            uint glyphCount = font.NumGlyphs;

            for (int i = 0; i < glyphCount; i++)
            {
                ZoneTable[i].ToSwf(w);
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 60
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);
            TextBounds.ToSwf(w);
            TextMatrix.ToSwf(w);

            w.AppendByte((byte)glyphBits); // TODO: gen nbits
            w.AppendByte((byte)advanceBits); // TODO: gen nbits

            for (int i = 0; i < TextRecords.Count; i++)
            {
                TextRecords[i].ToSwf(w, glyphBits, advanceBits, tagType >= TagType.DefineText2);
            }

            w.AppendByte(0); // end

            w.ResetLongTagLength(this.TagType, start, true);
        }