1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| // Permet de sauvegarder l'image d'origine
Image ori;
// Remplace les pixels noir opaque (noir complet) par du rouge (respecte la transparence)
private void button1_Click(object sender, EventArgs e)
{
if (ori == null)
ori = pictureBox1.Image;
Color oldColor = Color.Black;
Color newColor = Color.Red;
Bitmap bmp = new Bitmap(ori);
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++)
{
Color gotColor = bmp.GetPixel(x, y);
if (gotColor.ToArgb() == oldColor.ToArgb())
bmp.SetPixel(x, y, newColor);
}
pictureBox1.Image = bmp;
}
// Remplace les pixels noir qui ne sont pas complètement transparent par rouge (ne respecte pas la transparence)
private void button2_Click(object sender, EventArgs e)
{
if (ori == null)
ori = pictureBox1.Image;
Color oldColor = Color.Black;
Color newColor = Color.Red;
Bitmap bmp = new Bitmap(ori);
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++)
{
Color gotColor = bmp.GetPixel(x, y);
if (gotColor.A > 0 && Color.FromArgb(0, gotColor) == Color.FromArgb(0, oldColor))
bmp.SetPixel(x, y, Color.FromArgb(255, newColor));
}
pictureBox1.Image = bmp;
}
// Remplace tous les pixels par du rouge (respecte la transparence)
private void button3_Click(object sender, EventArgs e)
{
if (ori == null)
ori = pictureBox1.Image;
Color newColor = Color.Red;
Bitmap bmp = new Bitmap(ori);
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++)
{
Color gotColor = bmp.GetPixel(x, y);
bmp.SetPixel(x, y, Color.FromArgb(gotColor.A, newColor));
}
pictureBox1.Image = bmp;
}
// Remplace les pixels noir qui ne sont pas complétement transparent par du rouge (respecte la transparence)
private void button4_Click(object sender, EventArgs e)
{
if (ori == null)
ori = pictureBox1.Image;
Color oldColor = Color.Black;
Color newColor = Color.Red;
Bitmap bmp = new Bitmap(ori);
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++)
{
Color gotColor = bmp.GetPixel(x, y);
if (gotColor.A > 0 && Color.FromArgb(0, gotColor) == Color.FromArgb(0, oldColor))
bmp.SetPixel(x, y, Color.FromArgb(gotColor.A, newColor));
}
pictureBox1.Image = bmp;
} |
Partager