gpt4 book ai didi

c++ - 如何从字节数组中读取 8 位位图像素颜色和位置

转载 作者:行者123 更新时间:2023-11-28 03:35:54 25 4
gpt4 key购买 nike

我目前将 8 位位图的像素数据存储在一个字节数组中:BYTE* pixelData

我现在如何编写自己的函数以根据像素的位置返回像素的颜色?我已经进行了大量搜索,但没有找到使用 C++ 涵盖此内容的任何内容。

最佳答案

BYTE GetPixelColor(BYTE* src, int x, int y, int srcWidth)
{
return src[y * srcWidth + x];
}

...
//suppose you have a 800 x 600 bmp, to get the color for pixel at x 30, y 200
BYTE color = GetPixelColor(src, 30, 200, 800);

关于c++ - 如何从字节数组中读取 8 位位图像素颜色和位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10871879/

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