I am trying to increase the red value of an image by fifty percent. Here is my code:
public static Bitmap IncreaseRedFiftyPercent(Bitmap b)
{
Bitmap temp = (Bitmap) b;
Bitmap bmap = (Bitmap)temp.Clone();
Color c;
for (int i = 0; i < bmap.Width; i++)
{
for (int j = 0; j < bmap.Height; j++)
{
c = bmap.GetPixel(i, j);
byte increase = c.R + c.R * 0.5; //This line gives error
bmap.SetPixel(i, j, Color.FromArgb(increase, c.G, c.B));
}
}
b = (Bitmap)bmap.Clone();
return b;
}
Here is what i do: I read all pixels of the picture, and increase the red value by fifty percent and keep blue and green the same. But the line
byte increase = c.R + c.R * 0.5; //This line gives error
gives me an error saying that
Cannot implicitly convert type 'double' to 'byte'. An explicit conversion exists (are you missing
a cast?)
And i cannot convert double to byte? It looks like sensible what i am doing, what is wrong here?
Thanks