예제 #1
0
        private static SMXFrameHeader ReadSMXFrameHeader(BinaryReader reader)
        {
            var frameType        = (SMXFrameType)reader.ReadByte();
            var paletteNumber    = reader.ReadByte();
            var uncompressedSize = reader.ReadInt32();

            var compression = ((int)frameType & 0b_0000_1000) == 0
                ? SMXFrameCompression.FourPlusOne
                : SMXFrameCompression.EightToFive;

            var smxFrameHeader = new SMXFrameHeader
            {
                Kind             = (SMXFrameType)frameType,
                Compression      = compression,
                PaletteNumber    = paletteNumber,
                UncompressedSize = uncompressedSize,
            };

            if (IsVerbose)
            {
                Console.WriteLine("\tFrame Header");
                Console.WriteLine("\t{0}", new string('-', Repeat));
                Console.WriteLine("\tFrameType         : [{0}], Compression: {1}", smxFrameHeader.Kind, smxFrameHeader.Compression);
                Console.WriteLine("\tPalette Number    : {0}, '{1}'", smxFrameHeader.PaletteNumber, _palettes[paletteNumber]);
                Console.WriteLine("\tUncompressed Size : {0} bytes", smxFrameHeader.UncompressedSize);
                Console.WriteLine("\t{0}", new string('-', Repeat));
            }

            return(smxFrameHeader);
        }
예제 #2
0
        private static IList <SMXLayer> ReadSMXLayers(SMXFrameHeader smxFrameHeader, BinaryReader reader)
        {
            var result = new List <SMXLayer>();

            if (smxFrameHeader.HasGraphics())
            {
                var smxLayerHeader       = ReadSMXLayerHeader(reader);
                var smxLayerRowEdgeArray = ReadSMXLayerRowEdgeArray(smxLayerHeader, reader);
                var graphics             = ReadGraphics(smxLayerHeader, smxFrameHeader.PaletteNumber, smxFrameHeader.Compression, smxLayerRowEdgeArray, reader);

                result.Add(new SMXLayer
                {
                    Header   = smxLayerHeader,
                    Edges    = smxLayerRowEdgeArray,
                    Graphics = graphics,
                });
            }

            if (smxFrameHeader.HasShadow())
            {
                var smxLayerHeader       = ReadSMXLayerHeader(reader);
                var smxLayerRowEdgeArray = ReadSMXLayerRowEdgeArray(smxLayerHeader, reader);
                var graphics             = ReadShadow(smxLayerHeader, smxLayerRowEdgeArray, reader);

                result.Add(new SMXLayer
                {
                    Header   = smxLayerHeader,
                    Edges    = smxLayerRowEdgeArray,
                    Graphics = graphics,
                });
            }

            if (smxFrameHeader.HasOutline())
            {
                var smxLayerHeader       = ReadSMXLayerHeader(reader);
                var smxLayerRowEdgeArray = ReadSMXLayerRowEdgeArray(smxLayerHeader, reader);
                var graphics             = ReadOutline(smxLayerHeader, smxLayerRowEdgeArray, reader);

                result.Add(new SMXLayer
                {
                    Header   = smxLayerHeader,
                    Edges    = smxLayerRowEdgeArray,
                    Graphics = graphics,
                });
            }

            return(result);
        }