Reputation: 4741
I create a c# function that moves BitmapFrame picture to byte[] (using copypixels). Then I paste this buffer into c++ dll where it is uint8*. There is a structure in 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 x y - height and width of image(this data I have too))? 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
So simple uint8 -> getPixel(x,y) ????
Upvotes: 1
Views: 3160
Reputation: 1866
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
}
}
Upvotes: 1