using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; namespace Rip81Font { public partial class Form1 : Form { private byte[] rom; public Form1() { InitializeComponent(); rom = File.ReadAllBytes("Data/zx81.bin"); m_pictureBox.Image = new Bitmap(8, 8); } private void Rip(int code) { bool inv = false; if (code > 127) { inv = true; code -= 128; } if (code > 63) { using (Graphics g = Graphics.FromImage(m_pictureBox.Image)) { g.FillRectangle(Brushes.Red, 0, 0, 8, 8); } } else { int addr = 0x1e00 + code * 8; using (Graphics g = Graphics.FromImage(m_pictureBox.Image)) { for(int f = 0; f < 8; f++) { byte b = rom[addr+f]; for(int n = 0; n < 8; n++) { Brush p; if ((b & (1 << n)) != 0) { if (inv) { p = Brushes.White; } else { p = Brushes.Black; } } else { if (inv) { p = Brushes.Black; } else { p = Brushes.White; } } g.FillRectangle(p, 7 - n, f, 1, 1); } } } } using (Graphics g = m_pictureBox.CreateGraphics()) { g.DrawImageUnscaled(m_pictureBox.Image, 0, 0); } } private void OnCodeChanged(object sender, EventArgs e) { Rip(Convert.ToInt32(m_number.Value)); } private void OnExportAll(object sender, EventArgs e) { Directory.CreateDirectory("Export"); for(int f = 0; f < 256; f++) { Rip(f); string fname = String.Format("Export/{0}.png", f); m_pictureBox.Image.Save(fname, ImageFormat.Png); } } } }