I wanna create coordinate axis on pictureBox1(bottom layer) and a letter on pictureBox2(top layer), but I cant make the top layer transparent. I try to change backColor, but it is
t working. And I know, that I`m not first. I tried to find a solution but couldn't
enter image description here
private void button2_Click(object sender, EventArgs e) //create a letter
{
Graphics gr = pictureBox2.CreateGraphics();
int size = Convert.ToInt32(textBox1.Text);
Pen redPen = new Pen(Color.Red, size);
redPen.DashStyle = DashStyle.Solid;
for (int i = 0; i <= 11; i++) {
gr.DrawLine(redPen, x[i], y[i], x[i+1], y[i+1]);
}
for (int i =0; i < 2; i++){
gr.DrawEllipse(redPen, x1[i], y1[i], 25, 25);
}
}
private void button11_Click(object sender, EventArgs e) //create coordinate axis
{
Graphics gr = pictureBox1.CreateGraphics();
int[] cx = new int[11];
int[] cy = new int[11];
int xs1 = 0, xs2 = 500, ys1 = 500, ys2 = 0;
int hx, hy, k = 10;
hx = (xs2 - xs1) / k;
hy = (ys2 - ys1) / k;
for (int i = 0; i <= k; i++)
{
cx[i] += xs1 + hx * i;
}
for (int j = 0; j <= k; j++)
{
cy[j] = ys1 + hy * j;
}
for (int i = 0; i <= k; i++)
{
gr.DrawLine(Pens.Aqua, cx[i], ys1, cx[i], ys2);
}
for (int j = 0; j <= k; j++)
{
gr.DrawLine(Pens.Aqua, xs1, cy[j], xs2, cy[j]);
}
gr.DrawLine(Pens.Black, cx[5], ys1, cx[5], ys2);
gr.DrawLine(Pens.Black, xs1, cy[5], xs2, cy[5]);
}
it doesn't work too
Bitmap bitmap = new Bitmap(pictureBox2.Image);
var bt = MakeTransparent(bitmap, Color.White, 30);
pictureBox2.Image = bt;