コード例 #1
0
 public static ColorTransformRGB ReadColorTransformRGB(this ISwfStreamReader reader)
 {
     ColorTransformRGB transform;
     var hasAddTerms = reader.ReadBit();
     var hasMultTerms = reader.ReadBit();
     var bits = reader.ReadUnsignedBits(4);
     if (hasMultTerms) {
         transform.RedMultTerm = (short)reader.ReadSignedBits(bits);
         transform.GreenMultTerm = (short)reader.ReadSignedBits(bits);
         transform.BlueMultTerm = (short)reader.ReadSignedBits(bits);
         transform.HasMultTerms = true;
     } else {
         transform.RedMultTerm = 0;
         transform.GreenMultTerm = 0;
         transform.BlueMultTerm = 0;
         transform.HasMultTerms = false;
     }
     if (hasAddTerms) {
         transform.RedAddTerm = (short)reader.ReadSignedBits(bits);
         transform.GreenAddTerm = (short)reader.ReadSignedBits(bits);
         transform.BlueAddTerm = (short)reader.ReadSignedBits(bits);
         transform.HasAddTerms = true;
     } else {
         transform.RedAddTerm = 0;
         transform.GreenAddTerm = 0;
         transform.BlueAddTerm = 0;
         transform.HasAddTerms = false;
     }
     reader.AlignToByte();
     return transform;
 }
コード例 #2
0
ファイル: ButtonStreamExt.cs プロジェクト: liwq-net/SwfLib
 public static ButtonRecordEx ReadButtonRecordEx(this ISwfStreamReader reader)
 {
     var button = new ButtonRecordEx();
     button.Reserved = (byte)reader.ReadUnsignedBits(2);
     var hasBlendMode = reader.ReadBit();
     var hasFilterList = reader.ReadBit();
     button.StateHitTest = reader.ReadBit();
     button.StateDown = reader.ReadBit();
     button.StateOver = reader.ReadBit();
     button.StateUp = reader.ReadBit();
     var isEnd = !hasBlendMode && !hasFilterList && button.IsEndButton;
     if (!isEnd) {
         button.CharacterID = reader.ReadUInt16();
         button.PlaceDepth = reader.ReadUInt16();
         button.PlaceMatrix = reader.ReadMatrix();
         button.ColorTransform = reader.ReadColorTransformRGBA();
         reader.AlignToByte();
         if (hasFilterList) {
             reader.ReadFilterList(button.Filters);
         }
         if (hasBlendMode) {
             button.BlendMode = (BlendMode)reader.ReadByte();
         }
     }
     return button;
 }
コード例 #3
0
 public static void ReadColorTransformRGBA(this ISwfStreamReader reader, out ColorTransformRGBA transform)
 {
     var hasAddTerms = reader.ReadBit();
     var hasMultTerms = reader.ReadBit();
     var bits = reader.ReadUnsignedBits(4);
     if (hasMultTerms) {
         transform.RedMultTerm = (short)reader.ReadSignedBits(bits);
         transform.GreenMultTerm = (short)reader.ReadSignedBits(bits);
         transform.BlueMultTerm = (short)reader.ReadSignedBits(bits);
         transform.AlphaMultTerm = (short)reader.ReadSignedBits(bits);
         transform.HasMultTerms = true;
     } else {
         transform.RedMultTerm = 0;
         transform.GreenMultTerm = 0;
         transform.BlueMultTerm = 0;
         transform.AlphaMultTerm = 0;
         transform.HasMultTerms = false;
     }
     if (hasAddTerms) {
         transform.RedAddTerm = (short)reader.ReadSignedBits(bits);
         transform.GreenAddTerm = (short)reader.ReadSignedBits(bits);
         transform.BlueAddTerm = (short)reader.ReadSignedBits(bits);
         transform.AlphaAddTerm = (short)reader.ReadSignedBits(bits);
         transform.HasAddTerms = true;
     } else {
         transform.RedAddTerm = 0;
         transform.GreenAddTerm = 0;
         transform.BlueAddTerm = 0;
         transform.AlphaAddTerm = 0;
         transform.HasAddTerms = false;
     }
     reader.AlignToByte();
 }
コード例 #4
0
ファイル: SwfStreamReaderExt.cs プロジェクト: liwq-net/SwfLib
 public static void ReadRect(this ISwfStreamReader reader, out SwfRect rect)
 {
     var bits = reader.ReadUnsignedBits(5);
     rect.XMin = reader.ReadSignedBits(bits);
     rect.XMax = reader.ReadSignedBits(bits);
     rect.YMin = reader.ReadSignedBits(bits);
     rect.YMax = reader.ReadSignedBits(bits);
     reader.AlignToByte();
 }
コード例 #5
0
 public static void ReadToShapeRecordsRGBA(this ISwfStreamReader reader, IList<IShapeRecordRGBA> shapeRecords)
 {
     var fillStyleBits = reader.ReadUnsignedBits(4);
     var lineStyleBits = reader.ReadUnsignedBits(4);
     reader.AlignToByte();
     IShapeRecordRGBA record;
     do {
         record = _shapeRecordRGBAReader.Read(reader, true, ref fillStyleBits, ref lineStyleBits);
         shapeRecords.Add(record);
     } while (!(record is EndShapeRecord));
 }
コード例 #6
0
ファイル: SwfStreamReaderExt.cs プロジェクト: liwq-net/SwfLib
 public static SwfMatrix ReadMatrix(this ISwfStreamReader reader)
 {
     var matrix = SwfMatrix.Identity;
     var hasScale = reader.ReadBit();
     if (hasScale) {
         var bits = (byte)reader.ReadUnsignedBits(5);
         matrix.ScaleX = reader.ReadFixedPoint16(bits);
         matrix.ScaleY = reader.ReadFixedPoint16(bits);
     }
     var hasRotate = reader.ReadBit();
     if (hasRotate) {
         var bits = (byte)reader.ReadUnsignedBits(5);
         matrix.RotateSkew0 = reader.ReadFixedPoint16(bits);
         matrix.RotateSkew1 = reader.ReadFixedPoint16(bits);
     }
     var translateBits = (byte)reader.ReadUnsignedBits(5);
     matrix.TranslateX = reader.ReadSignedBits(translateBits);
     matrix.TranslateY = reader.ReadSignedBits(translateBits);
     reader.AlignToByte();
     return matrix;
 }
コード例 #7
0
ファイル: TextStreamExt.cs プロジェクト: liwq-net/SwfLib
        public static IList<TextRecordRGB> ReadTextRecordsRGB(this ISwfStreamReader reader, uint glyphBits, uint advanceBits)
        {
            var res = new List<TextRecordRGB>();
            bool isEnd;
            do {
                var record = new TextRecordRGB();
                record.Type = reader.ReadBit();
                record.Reserved = (byte)reader.ReadUnsignedBits(3);
                var hasFont = reader.ReadBit();
                var hasColor = reader.ReadBit();
                var hasYOffset = reader.ReadBit();
                var hasXOffset = reader.ReadBit();

                isEnd = !record.Type && record.Reserved == 0 && !hasFont && !hasColor && !hasYOffset && !hasXOffset;

                if (!isEnd) {
                    record.FontID = hasFont ? (ushort?)reader.ReadUInt16() : null;
                    if (hasColor) {
                        record.TextColor = reader.ReadRGB();
                    }
                    if (hasXOffset) {
                        record.XOffset = reader.ReadSInt16();
                    }
                    if (hasYOffset) {
                        record.YOffset = reader.ReadSInt16();
                    }
                    if (hasFont) {
                        record.TextHeight = reader.ReadUInt16();
                    }
                    var count = reader.ReadByte();
                    for (var i = 0; i < count; i++) {
                        var entry = reader.ReadGlyphEntry(glyphBits, advanceBits);
                        record.Glyphs.Add(entry);
                    }
                    reader.AlignToByte();
                }
                res.Add(record);
            } while (!isEnd);
            return res;
        }