/// <summary> /// The IFrame is a colour setting for EVERY Pixel - the dimensions can be guessed at /// </summary> /// <param name="f">I Framedef</param> /// <returns>Parsed IFrame</returns> private IFrameDef GetIFrame(FrameDef f) { IFrameDef result = new IFrameDef() { PalIndex = new List <byte>() }; if (f.Type != FrameType.I) { return(result); } if (f.Count != f.Data.Length / 2) { Console.WriteLine($" ERROR IFrame length mismatch !! {f.Count} vs actual {f.Data.Length / 2}"); return(result); } Width = (ushort)Math.Sqrt(f.Count); Height = (ushort)(f.Count / Width); Console.WriteLine($" IFrame dimension {Width}x{Height}"); for (int i = 0; i < f.Count; i++) { result.PalIndex.Add(byte.Parse(f.Data.Substring(i * 2, 2), NumberStyles.AllowHexSpecifier)); } return(result); }
/// <summary> /// Use the meadow graphics library to draw the expressive pixels - I Frame /// </summary> private void Display(IFrameDef ifd, ushort xPos, ushort yPos, ushort zoom) { int x = xPos; int y = yPos; foreach (var p in ifd.PalIndex) { if (zoom == 1) { graphics.DrawPixel(x, y, Pallette[p]); x += 1; if (x - xPos >= Width) { x = xPos; y += 1; } } else if (zoom == 2 || zoom == 3) { graphics.Stroke = zoom; graphics.DrawLine(x, y, x + zoom - 1, y, Pallette[p]); x += zoom; if (x - xPos >= Width * zoom) { x = xPos; y += zoom; } } else { graphics.DrawRectangle(x, y, zoom, zoom, Pallette[p], true); x += zoom; if (x - xPos >= Width * zoom) { x = xPos; y += zoom; } } } }