I want to store the byte value of aFloat in pixelsArray for each 3D coordinate, in a 1D array:
float aFloat = 1.0;
unsigned char* pixelsArray = new unsigned char[HEIGHT*WIDTH*3];
for (int i = 0; i < HEIGHT; i++)
{
for (int j = 0; j < WIDTH; j++)
{
for (int k = 0; k < 3; k++)
{
pixelsArray[?] = aFloat;
}
}
}
What would go in the ?? I think it also needs to have + sizeof(float) somewhere in the index if I’m not mistaken.
Your inside line needs to be:
This should give you an all-white image.
Make sure your target is really three bytes per pixel and not four (alpha channel or padding); if it is four, you’ll just need to change the
3above to a4.