Hot answers tagged

10

You have mixed them a little in your head but we are here. :) Firstly, the line RGBTRIPLE triple; doesn't get a pixel, it just declares a variable, of type RGBTRIPLE with the name triple. It would be the same as int count; nothing less, nothing more. All the information, is passed to triple, through fread(). fread() takes 4 arguments: buffer - ...


2

I realise that this question is over a year old, however other people may still be having the issue so thought I would answer. I have had exactly the same issue - for me, the problem was caused by being on Windows 10 and having altered the "customise display" setting "Change the size of text, apps, and other items" from the recommended 125% to 100%. I have ...


1

You use bi.biWidth (in your case the output width at that point) both in for (int j = 0; j < bi.biWidth; j++) (found twice) and fseek(inptr, (bi.biWidth * sizeof(RGBTRIPLE)) * -1, SEEK_CUR); In both cases, you would have to use input width, not output width. Same is true for the height, though it would cause a larger file, but no visible distortion ...


1

Have you tried the steps described in the problem statement's "Testing" chapter? https://docs.cs50.net/2018/x/psets/4/resize/less/resize.html#testing The total file size is part of the BITMAPFILEHEADER. As far as I know, there are a few other fields containing various size information, most of them are optional in case of a simple non-compressed image (we ...


1

It all has to do with padding and repositioning with fseek. If the code isn't repositiioning correctly, the code won't be aligned with the beginning of a line of pixels. When that happens the padding gets used as if it were part of a pixel. Think about this. A red pixel looks like 00ff00. Now, say that the code is copying two pixels, but the file pointer ...


1

Your problem is with your fseek()s. You should fseek() back to beginning of the current line each time you read all the pixels of this line. You should do this n times for each line. You should fseek() at the beginning of the next line after the n-th time you print a line. Also, when you want to fseek() backwards, the offset parameter should be negative. ...


Only top voted, non community-wiki answers of a minimum length are eligible