I created a white image with this code:
#include "stb_image/stb_image.h"
#include "stb_image/stb_image_write.h"
int main(void){
int width = 1440;
int height = 1080;
int j, l;
float *img_slopes = (float *)malloc(width * height * sizeof(float));
for (l = 0; l < width; l++) {
for (j = 0; j < height; j++) {
*(img_slopes + j * width + l) = 255;
}
}
stbi_write_bmp("answer_blank.bmp", width, height, 1, img_slopes);
}
Those cycles should scroll through each and every pixel. But the output is:
png screen-capture of the answer_blank.bmp
Why is that? Why do I have black columns? What exactly is happening here?
If it's not clear enough from the print-screen, every other column is black.
As user @Gerhadh kindly mentioned, the .bmp don't use float
vales. It should be an unsigned char
matrix instead.