Paint.CanvasRecorder.Save C# (CSharp) 메소드

Save() 공개 메소드

Save the Canvas to file ready for playback.
public Save ( string filename ) : void
filename string
리턴 void
        public void Save(string filename)
        {
            using (FileStream stream = File.Open(filename, FileMode.Create, FileAccess.Write))
            {
                int commandCount = this.commandList.Count / BytesPerCommand;

                // Write the command length
                stream.WriteByte((byte)commandCount);
                stream.WriteByte((byte)(commandCount >> 8));
                stream.WriteByte((byte)(commandCount >> 16));
                stream.WriteByte((byte)(commandCount >> 24));

                // Write the current brush size and color - this is required so that anyone continuing with this playback
                // file at a later time doesn't have to parse all the existing commands to know what color to continue
                // with
                stream.WriteByte((byte)this.currentBrushSize);
                stream.WriteByte((byte)(this.currentBrushSize >> 8));
                stream.WriteByte((byte)(this.currentBrushSize >> 16));
                stream.WriteByte((byte)(this.currentBrushSize >> 24));

                stream.WriteByte((byte)this.currentColor.A);
                stream.WriteByte((byte)this.currentColor.R);
                stream.WriteByte((byte)this.currentColor.G);
                stream.WriteByte((byte)this.currentColor.B);

                // Write all the commands
                stream.Write(this.commandList.ToArray(), 0, this.commandList.Count);
            }
        }