画像の赤の値を 50% 上げようとしています。これが私のコードです:
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;
}
これが私がすることです: 私は画像のすべてのピクセルを読み取り、赤の値を 50% 増やし、青と緑を同じに保ちます。しかし、ライン
byte increase = c.R + c.R * 0.5; //This line gives error
と言うエラーが表示されます
Cannot implicitly convert type 'double' to 'byte'. An explicit conversion exists (are you missing
a cast?)
そして、私はダブルをバイトに変換できませんか? 私がやっていることは理にかなっているように見えますが、ここで何が悪いのですか?
ありがとう