internal 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); } }
internal override 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); }
internal override 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); }
internal override 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); }
internal override 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); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(SoundId); SoundInfo.ToSwf(w); w.ResetLongTagLength(this.TagType, start, true); }
internal override 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); }
internal override 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); }
internal override 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); }
internal override 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); }
internal override void ToSwf(SwfWriter w) { return; // NOT YET HANDLED uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendByte((byte)MajorVersion); w.AppendByte((byte)MinorVersion); w.AppendInt32(Product); w.AppendInt32(Edition); //w.AppendBytes(build); //w.AppendBytes(compilationDate); w.ResetLongTagLength(this.TagType, start, true); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendByte((byte)ButtonId); for (int i = 0; i < Characters.Count; i++) { Characters[i].ToSwf(w); } ActionRecords.ToSwf(w); w.ResetLongTagLength(this.TagType, start, true); }
internal override 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); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(CharacterId); 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); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); // rewrite len after tag w.AppendUI16(this.CharacterId); this.ShapeBounds.ToSwf(w); this.EdgeBounds.ToSwf(w); w.AppendBits(0, 6); w.AppendBit(this.UsesNonScalingStrokes); w.AppendBit(this.UsesScalingStrokes); this.Shapes.ToSwf(w, ShapeType.DefineShape4); w.Align(); w.ResetLongTagLength(this.TagType, start, true); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(ButtonId); w.AppendUI16(ButtonSoundChar0); ButtonSoundInfo0.ToSwf(w); w.AppendUI16(ButtonSoundChar1); ButtonSoundInfo1.ToSwf(w); w.AppendUI16(ButtonSoundChar2); ButtonSoundInfo2.ToSwf(w); w.AppendUI16(ButtonSoundChar3); ButtonSoundInfo3.ToSwf(w); w.ResetLongTagLength(this.TagType, start, true); }
internal override 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); }
internal override 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); }
internal override 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); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); // rewrite len after tag w.AppendUI16(this.CharacterId); this.ShapeBounds.ToSwf(w); if (tagType == TagType.DefineShape) { this.Shapes.ToSwf(w, ShapeType.DefineShape1); } else if (tagType == TagType.DefineShape2) { this.Shapes.ToSwf(w, ShapeType.DefineShape2); } else if (tagType == TagType.DefineShape3) { this.Shapes.ToSwf(w, ShapeType.DefineShape3); } w.Align(); w.ResetLongTagLength(this.TagType, start, true); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(SoundId); w.AppendBits((uint)SoundFormat, 4); switch (SoundRate) { case 5512: w.AppendBits(0, 2); break; case 11025: w.AppendBits(1, 2); break; case 22050: w.AppendBits(2, 2); break; case 44100: w.AppendBits(3, 2); break; } w.AppendBit(SoundSize == 16U); w.AppendBit(IsStereo); w.Align(); w.AppendUI32(SoundSampleCount); w.AppendBytes(SoundData); w.ResetLongTagLength(this.TagType, start); }
internal override void ToSwf(SwfWriter w) { 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.AppendBits(0, 5); // reserved w.AppendBit(PlaceFlagHasCacheAsBitmap); w.AppendBit(PlaceFlagHasBlendMode); w.AppendBit(PlaceFlagHasFilterList); 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 (PlaceFlagHasFilterList) { w.AppendByte((byte)FilterList.Count); for (int i = 0; i < FilterList.Count; i++) { FilterList[i].ToSwf(w); } } if (PlaceFlagHasBlendMode) { w.AppendByte((byte)BlendMode); } if (HasClipActions) { //todo: ClipActions = new ClipActions(); } w.ResetLongTagLength(this.TagType, start); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(FontId); w.AppendBit(FontFlagsHasLayout); w.AppendBit(FontFlagsShiftJIS); w.AppendBit(FontFlagsSmallText); w.AppendBit(FontFlagsANSI); w.AppendBit(FontFlagsWideOffsets); w.AppendBit(FontFlagsWideCodes); w.AppendBit(FontFlagsItalic); w.AppendBit(FontFlagsBold); w.Align(); w.AppendByte((byte)LanguageCode); w.AppendByte((byte)(FontName.Length + 1)); // add trailing /0 w.AppendString(FontName, (uint)FontName.Length); w.AppendUI16(NumGlyphs); for (int i = 0; i < this.NumGlyphs; i++) { if (this.FontFlagsWideOffsets) { w.AppendUI32(this.OffsetTable[i]); } else { w.AppendUI16(this.OffsetTable[i]); } } if (this.FontFlagsWideOffsets) { w.AppendUI32(this.CodeTableOffset); } else { w.AppendUI16(this.CodeTableOffset); } for (int i = 0; i < this.NumGlyphs; i++) { GlyphShapeTable[i].ToSwf(w); } for (int i = 0; i < this.NumGlyphs; i++) { w.AppendUI16(this.CodeTable[i]); } if (this.FontFlagsHasLayout) { w.AppendInt16(FontAscent); w.AppendInt16(FontDescent); w.AppendInt16(FontLeading); for (int i = 0; i < this.NumGlyphs; i++) { w.AppendInt16(this.FontAdvanceTable[i]); } for (int i = 0; i < this.NumGlyphs; i++) { this.FontBoundsTable[i].ToSwf(w); } w.AppendUI16(this.KerningCount); if (this.FontFlagsWideCodes) { for (int i = 0; i < this.KerningCount; i++) { w.AppendUI16(this.FontKerningTable[i].FontKerningCode1); w.AppendUI16(this.FontKerningTable[i].FontKerningCode2); w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment); } } else { for (int i = 0; i < this.KerningCount; i++) { w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode1); w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode2); w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment); } } } w.ResetLongTagLength(this.TagType, start, true); }
internal override 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 = ByteReader.Compress(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 = ByteReader.Compress(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 = ByteReader.Compress(mapData); if (OrgBitmapData != null) { w.AppendBytes(OrgBitmapData); } else { w.AppendBytes(zipped); } } w.ResetLongTagLength(this.TagType, start, true); }