怎么用 C# 根据提供的 RGB 数据,生成 BMP 图片
1个回答
展开全部
FileInfo fi1 = new FileInfo(保存路径 + "s_cover.jpg");
FileStream fs1 = fi1.OpenRead();
System.Drawing.Image Img1 = System.Drawing.Image.FromStream(fs1);
Bitmap bmp = new Bitmap(Img1);//可以设定图片的大小
for (int X = 0; X < bmp.Width; X++)
{
for (int Y = 0; Y < bmp.Height; Y++)
{
Color rgb = bmp.GetPixel(X, Y);
byte bBlue = rgb.B;
byte bRed = rgb.R;
byte bGreen = rgb.G;
int color = (9798 * bRed + 19235 * bGreen + 3735 * bBlue) / 32768;
Color NewColor = Color.FromArgb(color, color, color);
bmp.SetPixel(X, Y, NewColor);
}
}
bmp.Save(保存路径 + "s_cover1.jpg", ImageFormat.Jpeg);
bmp.Dispose();
fs1.Dispose();
fs1.Close();
FileStream fs1 = fi1.OpenRead();
System.Drawing.Image Img1 = System.Drawing.Image.FromStream(fs1);
Bitmap bmp = new Bitmap(Img1);//可以设定图片的大小
for (int X = 0; X < bmp.Width; X++)
{
for (int Y = 0; Y < bmp.Height; Y++)
{
Color rgb = bmp.GetPixel(X, Y);
byte bBlue = rgb.B;
byte bRed = rgb.R;
byte bGreen = rgb.G;
int color = (9798 * bRed + 19235 * bGreen + 3735 * bBlue) / 32768;
Color NewColor = Color.FromArgb(color, color, color);
bmp.SetPixel(X, Y, NewColor);
}
}
bmp.Save(保存路径 + "s_cover1.jpg", ImageFormat.Jpeg);
bmp.Dispose();
fs1.Dispose();
fs1.Close();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询