ReadInstruction() 공개 정적인 메소드

Read an instruction from the stream.
public static ReadInstruction ( Stream stream, PicturePatternFlags &patternFlags, byte &patternNumber ) : PictureInstruction
stream Stream
patternFlags PicturePatternFlags
patternNumber byte
리턴 PictureInstruction
예제 #1
0
        internal Picture(AssetLoader loader)
            : base(loader)
        {
            BinaryReader reader = loader.Reader;
            ushort       check  = reader.ReadUInt16();
            Codex <PictureInstruction> instructions = new Codex <PictureInstruction>();
            Codex <PictureCel>         cels         = new Codex <PictureCel>();

            if (check == 0x0E)               // VGA picture
            {
                int celCount = reader.ReadUInt16();
                Unknowns.ReadInt16s(reader, 1);                 // 0x2A
                int paletteOffset = reader.ReadInt32();
                Dimensions = new Vector2i(reader.ReadUInt16(), reader.ReadUInt16());

                reader.BaseStream.Position = paletteOffset;
                Palette = new Palette(loader);
                AddChild(Palette);

                for (int celIndex = 0; celIndex < celCount; celIndex++)
                {
                    PictureCel cel = new PictureCel(this, celIndex, loader);

                    cels.Add(cel);
                    AddChild(cel);
                    instructions.Add(new PictureInstruction.DrawCel(cel));
                }
            }
            else
            {
                Dimensions = new Vector2i(320, 190);
                reader.BaseStream.Seek(-2, SeekOrigin.Current);
                byte[] data   = reader.ReadBytes(checked ((int)reader.BaseStream.Length));
                Stream stream = new MemoryStream(data, false);
                PicturePatternFlags patternFlags = PicturePatternFlags.None;
                byte patternNumber = 0;

                while (true)
                {
                    PictureInstruction instruction = PictureInstruction.ReadInstruction(stream, ref patternFlags, ref patternNumber);
                    instructions.Add(instruction);
                    if (instruction.IsQuit)
                    {
                        break;
                    }
                }
            }

            Cels         = cels;
            Instructions = instructions;
        }