[英]get RGB pixel values from uint8 c++
I create ac# function that moves BitmapFrame picture to byte[] (using copypixels). 我创建了一个ac#函数,将BitmapFrame图片移动到byte [](使用copypixels)。 Then I paste this buffer into c++ dll where it is uint8*.
然后,我将此缓冲区粘贴到uint8 *所在的c ++ dll中。 There is a structure in cpp
cpp中有一个结构
typedef struct
{
float r;
float g;
float b;
} pixel;
Is it possible to organize a loop for this uint8* buffer to get pixel-by pixel (for example by xy - height and width of image(this data I have too))? 是否可以为此uint8 *缓冲区组织一个循环以逐像素获取(例如,按xy-图像的高度和宽度(我也有此数据))? something like
就像是
for(i=0; i< height;i++)
{
for(j=0; j <width;j++)
{
SomeWorkWithPixelsfromUint8(i,j) //???
}
}
Where SomeWorkWithPixelsfromUint8(i,j) could operate RGB structure 来自Uint8(i,j)的SomeWorkWithPixels可以操作RGB结构的地方
So simple uint8 -> getPixel(x,y) ???? 如此简单的uint8-> getPixel(x,y)????
Assuming that your picture data have a layout like this 假设您的图片数据具有这样的布局
uint8_t* picData = ...;
uint8_t* pixel = picData;
for(int i = 0; i < height; ++i) {
for(int j = 0; j < width; ++j, pixel += pixelSize) {
float r = pixel[0];
float g = pixel[1];
float b = pixel[2];
// Do something with r, g, b
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.