private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if ((_tmpx == -1) || (_tmpy == -1)) return; int w = Math.Abs(e.X / 16 - _tmpx) + 1, h = Math.Abs(e.Y / 16 - _tmpy) + 1; var c = new byte[w * h]; int ox = _tmpx, oy = _tmpy; if (e.X / 16 < _tmpx) ox = e.X / 16; if (e.Y / 16 < _tmpy) oy = e.Y / 16; for (var x = ox; x < ox + w; x++) for (var y = oy; y < oy + h; y++) c[(y - oy) * w + (x - ox)] = (byte) (y * 16 + x); Chippack = new ChipPack(w, h, c); }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { var ex = e.X; var ey = e.Y; if (ex / 16 > 15) ex = 15 * 16; if (ey / 16 > 3) ey = 3 * 16; int w = Math.Abs(ex / 16 - _tmpx) + 1, h = Math.Abs(ey / 16 - _tmpy) + 1; var c = new byte[w * h]; int ox = _tmpx, oy = _tmpy; if (ex / 16 < _tmpx) ox = ex / 16; if (ey / 16 < _tmpy) oy = ey / 16; for (var x = ox; x < ox + w; x++) for (var y = oy; y < oy + h; y++) c[(y - oy) * w + (x - ox)] = (byte) (y * 16 + x); Chippack = new ChipPack(w, h, c); _tmpx = _tmpy = -1; }