private unsafe void Replace(object sender, EventArgs e) { if (pictureBox1.Image == null) { return; } if (ColorDisplay.Image == null || ColorDisplay2.Image == null) { MessageBox.Show("Please pick a color!"); return; } byte a1 = (byte)(alp1.Value); byte r1 = (byte)(red1.Value); byte g1 = (byte)(green1.Value); byte b1 = (byte)(blue1.Value); Bitmap b = (Bitmap)pictureBox1.Image; PicProcessor.RangeChecker RC = new PicProcessor.RangeChecker(main, a1, r1, g1, b1); PicProcessor.LockDaPic(b, (x, y, data) => { if (RC.IsColInrange(PicProcessor.ColorFrompointer(data, 32))) { data[0] = replacement.B; data[1] = replacement.G; data[2] = replacement.R; data[3] = replacement.A; } }); pictureBox1.Image = b; }
private void OnOpen(object sender, EventArgs e) { openFileDialog1.ShowDialog(); try { Bitmap local = new Bitmap(openFileDialog1.FileName); pictureBox1.Image = PicProcessor.CreateNonIndexedImage(local); } catch (Exception) { MessageBox.Show("Unable to open such file"); } }