0

I've been struggling with pset4 resize.c for a while now and I think I'm getting close to finishing :) When resizing everything seems to visually work out, but when using 'peek', the headers don't correlate to the correct numbers, mainly in biSizeImage and subsequently bfSize. Below the code that I've used for the headers, I hope anyone can see what I did and how I can improve this!

BITMAPFILEHEADER nbf = bf;
BITMAPINFOHEADER nbi = bi;

nbi.biHeight *= N;
nbi.biWidth *= N;

// determine padding for scanlines
int padding =  (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
int npadding = (4 - (nbi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;

nbi.biSizeImage = (((bi.biSizeImage - padding*bi.biHeight) * (N * N)) + npadding*nbi.biHeight);
nbf.bfSize = nbi.biSizeImage + 54;
1

You need to consider the fact that bi.biHeight is negative.

1
  • Thanks, this was exáctly the problem with my code! Two abs() functions fixed everything and passed it through check50 :D Mar 1 '16 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .