Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.StoreRegister);
            w.AppendUI16(Length - 3); // don't incude this part

            w.AppendByte((byte)Register);
        }
Esempio n. 8
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)PrimitiveType);
            byte b = (BooleanValue == true) ? (byte)0x01 : (byte)0x00;

            w.AppendByte(b);
        }
Esempio n. 9
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);
                }
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
     }
 }
Esempio n. 14
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);
            }
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
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);
            }
        }
Esempio n. 17
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);
            }
        }
Esempio n. 18
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);
        }
Esempio n. 19
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
        }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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;
            }
        }
Esempio n. 24
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);
        }
Esempio 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);
        }
Esempio n. 26
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);
        }
Esempio n. 27
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);
                }
            }
        }
Esempio n. 28
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;
            }
        }
Esempio 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);
        }
Esempio n. 30
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);
        }
Esempio n. 31
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();
        }
Esempio n. 32
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.DefineFunction2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendString(FunctionName);
            w.AppendUI16((uint)Parameters.Count);
            w.AppendByte((byte)RegisterCount);

            w.AppendBit((Preloads & PreloadFlags.Parent) > 0);
            w.AppendBit((Preloads & PreloadFlags.Root) > 0);
            w.AppendBit(SuppressSuperFlag);
            w.AppendBit((Preloads & PreloadFlags.Super) > 0);
            w.AppendBit(SuppressArgumentsFlag);
            w.AppendBit((Preloads & PreloadFlags.Arguments) > 0);
            w.AppendBit(SuppressThisFlag);
            w.AppendBit((Preloads & PreloadFlags.This) > 0);
            w.AppendBits(0, 7);
            w.AppendBit((Preloads & PreloadFlags.Global) > 0);

            foreach (KeyValuePair <uint, string> d in Parameters)
            {
                w.AppendByte((byte)d.Key);
                w.AppendString(d.Value);
            }

            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;
            }
        }
Esempio n. 33
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);
            }
        }
Esempio n. 34
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);
        }
Esempio n. 35
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);
            }
        }
Esempio n. 36
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);
        }
Esempio n. 37
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);
            }
        }
Esempio n. 38
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]);
        }
Esempio n. 39
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GetURL2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits((uint)SendVarsMethod, 2);
            w.AppendBits(0, 4);
            w.AppendBit(TargetIsSprite);
            w.AppendBit(LoadVariables);
            w.Align();
        }
Esempio n. 40
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]);
        }
Esempio n. 41
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);
        }
Esempio n. 42
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.GotoFrame2);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendBits(0, 6);
            w.AppendBit(SceneBiasFlag);
            w.AppendBit(PlayFlag);
            w.Align();
            if (SceneBiasFlag)
            {
                w.AppendUI16(SceneBias);
            }
        }
Esempio n. 43
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();
        }
Esempio n. 44
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.GetMember);
 }
Esempio n. 45
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.TargetPath);
 }
Esempio n. 46
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.Modulo);
 }
Esempio n. 47
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.ToggleQuality);
 }
Esempio n. 48
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.BitAnd);
 }
Esempio n. 49
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.CloneSprite);
 }
Esempio n. 50
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.PreviousFrame);
 }
Esempio n. 51
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(CharacterId);
            w.AppendByte((byte)BitmapFormat);
            w.AppendUI16(Width);
            w.AppendUI16(Height);

            if (BitmapFormat == BitmapFormat.Colormapped8Bit) // 8-bit colormapped image
            {
                w.AppendByte((byte)(ColorCount - 1));

                uint colorBytes = HasAlpha ? (uint)4 : (uint)3;
                uint padWidth = this.Width + (4 - (this.Width % 4));
                uint unzippedSize = (this.ColorCount * colorBytes) + (padWidth * this.Height);

                byte[] mapData = new byte[unzippedSize];

                for (int i = 0; i < this.ColorCount; i++)
                {
                    mapData[i * colorBytes + 0] = ColorTable[i].R;
                    mapData[i * colorBytes + 1] = ColorTable[i].G;
                    mapData[i * colorBytes + 2] = ColorTable[i].B;
                    if (HasAlpha)
                    {
                        mapData[i * colorBytes + 3] = ColorTable[i].A;
                    }
                }

                int index = 0;
                int st = (int)(this.ColorCount * colorBytes);
                for (int i = st; i < unzippedSize; i++)
                {
                    if (((i - st) % padWidth) < this.Width)// exclude padding
                    {
                        mapData[i] = (byte)this.ColorData[index++];
                    }
                    else
                    {
                        mapData[i] = 0;
                    }
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if(OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }

            }

            else if (BitmapFormat == BitmapFormat.RGB15Bit) // rbg 15
            {
                // todo: find a test file for rgb555
                uint colorBytes = 2;
                uint padWidth = this.Width * colorBytes;
                padWidth += (4 - padWidth) % 4;
                uint unzippedSize = (padWidth * this.Height) * colorBytes;

                byte[] mapData = new byte[unzippedSize];

                int index = 0;
                uint byteCount = padWidth * this.Height;
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    byte rd = this.BitmapData[index].R;
                    byte gr = this.BitmapData[index].G;
                    byte bl = this.BitmapData[index].B;

                    byte b0 = 0;
                    byte b1 = 0;
                    b0 |= (byte)((rd & 0x7C) << 1);
                    b0 |= (byte)((gr & 0x03) << 6);
                    b1 |= (byte)((gr & 0xE0) >> 2);
                    b1 |= (byte)((bl & 0x1F) << 3);

                    mapData[i + 0] = b0;
                    mapData[i + 1] = b1;

                    index++;
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if (OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }
            }

            else if (BitmapFormat == BitmapFormat.RGB24Bit) // RGB 24
            {
                uint colorBytes = HasAlpha ? (uint)4 : (uint)3;
                uint unzippedSize = (this.Width * this.Height) * colorBytes;

                byte[] mapData = new byte[unzippedSize];

                int index = 0;
                for (uint i = 0; i < unzippedSize; i += colorBytes)
                {
                    mapData[i + 0] = this.BitmapData[index].A;
                    mapData[i + 1] = this.BitmapData[index].R;
                    mapData[i + 2] = this.BitmapData[index].G;
                    if (HasAlpha)
                    {
                        mapData[i + 3] = this.BitmapData[index].B;
                    }
                    index++;
                }
                byte[] zipped = SwfWriter.ZipBytes(mapData);
                if (OrgBitmapData != null)
                {
                    w.AppendBytes(OrgBitmapData);
                }
                else
                {
                    w.AppendBytes(zipped);
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Esempio n. 52
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.Multiply);
 }
Esempio n. 53
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.Call);
     w.AppendUI16(Length - 3); // don't incude def byte and len
 }
Esempio n. 54
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.CastOp);
 }
Esempio n. 55
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.Decrement);
 }
Esempio n. 56
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.CallMethod);
 }
Esempio n. 57
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.StopSounds);
 }
Esempio n. 58
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);
        }
Esempio n. 59
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
        }
Esempio n. 60
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.EndDrag);
 }