gpt4 book ai didi

c# - 像素编程续

转载 作者:太空狗 更新时间:2023-10-29 23:42:45 25 4
gpt4 key购买 nike

我有一个 BGR 顺序的像素字节数组,我想用 C# 创建一个图像。谁能提供代码或建议?

最佳答案

效果(未测试)


private Bitmap createImage(int width, int height, byte[] image)
{
int index = 0;
byte r, g, b;
Bitmap bmp = new Bitmap(width, height);
for (y as int = 0; y < height; y++)
{
for (x as int = 0; x < width; x++)
{
b = image[y * width + index];
g = image[y * width + index + 1];
r = image[y * width + index + 2];
bmp.SetPixel(x, y, Color.FromArgb(255, r, g, b));
index += 3;
}
}
return bmp;
}

关于c# - 像素编程续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/392425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com