I've changed your code a bit to my vars
Code:
RGBTRIPLE **image = malloc(biHeight * sizeof(*image));
for (i = 0; i < biHeight; i++)
image[0] = malloc(bi.biWidth * sizeof(*image[0]));
for (i = 0; i < biHeight; i++)
for (j = 0; j < bi.biWidth; j++)
if (fread(image[i], sizeof(image[i][j]), bi.biWidth, inptr) != bi.biWidth * sizeof(image[i][j]))
{
perror("fread failed on original image");
return -1; // or whatever error code you want
}
But the line perror gets excuted all the time. I've seen your fread statement and everything seem right.
Both the height and the width get a value of 3. because my input bmp is 3 by 3.
What you cause it?