As yogiCsharp said:
private void Opacity(ref Bitmap image)
{
for (int w = 0; w < image.Width; w++)
{
for (int h = 0; h < image.Height; h++)
{
Color c = image.GetPixel(w, h);
if (c != Color.Transparent)
{
Color newC = Color.FromArgb(c.A/2, c.R/2,c.G/2,c.B);
image.SetPixel(w, h, newC);
}
}
}
}
As you can see, in the Color NewC line, I'm using half Alpha (A channel of the pixel), half Red (R channel of the image), half Green (G channel of the image), half Blue (B Channel of the image).
Also is better, so you can put the opacity in percetange on the oppacity parameter:
private void Opacity(ref Bitmap image, int opacity)
{
for (int w = 0; w < image.Width; w++)
{
for (int h = 0; h < image.Height; h++)
{
Color c = image.GetPixel(w, h);
if (c != Color.Transparent)
{
Color newC = Color.FromArgb(c.A*(opacity/100), c.R*(opacity/100),c.G*(opacity/100),c.B*(opacity/100));
image.SetPixel(w, h, newC);
}
}
}
}
Sorry for my english Spanish native speacker.