I'm having some trouble with the malloc function. I want to make a buffer the size of the new row I'm going to write in the resized file, and this is my approach.
I must say that bi.biWidth is already updated and specifies the value of the new row succesfully.
RGBTRIPLE* row = malloc(bi.biWidth*sizeof(RGBTRIPLE)); //Allocate memory the size of a bmp row excluding padding //For debugging purposes int sizeRow = sizeof(row); printf("%d\n", sizeRow); int sizeCalc= bi.biWidth*sizeof(RGBTRIPLE); printf("%d\n", sizeCalc);
if for example I want to resize smiley.bmp by a factor of 2, the results I get are:
sizeRow = 8 bytes.
sizeCalc = 48 bytes.
the calculation does output the correct number of bytes my row should have (without padding), but the size of the buffer is completely different.
I'm pretty sure is because I'm not implementing the malloc() function well, but I can't seem to find the problem myself. Any help?