/// <summary> /// Enable visual and priority layers, set the priority to that specified by the cel, then draw a <see cref="PictureCel"/>. /// </summary> /// <param name="cel"></param> public void DrawCel(PictureCel cel) { Canvas.Priority.SetColor(checked ((byte)cel.Priority)); DrawPriority = true; DrawVisual = true; DrawImage(cel.Offset, cel.Dimensions, cel.Indices, 0, cel.Pitch, cel.MaskIndex); }
/// <summary> /// Initialise the instruction. /// </summary> /// <param name="cel"></param> public DrawCel(PictureCel cel) : base(PictureExtendedOpcode.DrawCel) { if (cel == null) { throw new ArgumentNullException("cel"); } Cel = cel; }
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; }
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; }
/// <summary> /// Initialise the instruction. /// </summary> /// <param name="cel"></param> public DrawCel(PictureCel cel) : base(PictureExtendedOpcode.DrawCel) { if (cel == null) throw new ArgumentNullException("cel"); Cel = cel; }
/// <summary> /// Enable visual and priority layers, set the priority to that specified by the cel, then draw a <see cref="PictureCel"/>. /// </summary> /// <param name="cel"></param> public void DrawCel(PictureCel cel) { Canvas.Priority.SetColor(checked((byte)cel.Priority)); DrawPriority = true; DrawVisual = true; DrawImage(cel.Offset, cel.Dimensions, cel.Indices, 0, cel.Pitch, cel.MaskIndex); }