2 votes
Accepted

CS50 Pset4 Resize Padding

The issue is with your fseeks. To understand how this program should work, let's assume the original picture (I’ll call this infile for now) is the following: G G G padding G W G padding G G G ...
jwang1191's user avatar
2 votes
Accepted

pset4 Resize: Don't understand problems with size and dimensions

You have two problems, one with the header and one with image processing. In the header, you have calculated all the values correctly. (BTW, that was the most unique way I've seen to date to add the ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

pset4 Resize adding padding... and resize in general (HELP ME!)

Your code has a number of problems. Based on what you have said, and what is in the code, I think you'd benefit more from some guidance on how to work through this pset and some general advice. When ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Problem with horizontal resizing Pset4 resize

fwrite(&triple, sizeof(RGBTRIPLE), n, outptr); will write a chunk of memory containing n pixels, while you need to write the very same triple, n times. You'll have to use another loop for that.
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

CS50 Pset4 Resize Padding. again

If you look at the actual data of the output file, certain patterns become obvious. Say that the input file is being scaled up to 2. The first line from the input file is being scaled up correctly, ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Trouble with padding in resize

Two small problems with significant impact. First, the code calculates the output padding before calculating the output file width. This is disrupting the size of the output padding and two header ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

pset4 resize size is correct, but the pixel colors are all wrong

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 ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

pset4 resize.c error

This code is far from perfect. It incorrectly calculates biSizeImage. biSizeImage cannot simply be raised to a power. The biSizeImage of the new file must be calculated using the new padding size, ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

resize.c problem with padding

It would be easy to say what the problem is, but what fun would that be for you? ;-) The problem is only indirectly related to padding. You still don't have your header calculations right. When you ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

pset4 - resize: padding issue

I didn't go deep into your program because there's something you need to fix that will have a big effect on what is happening. I think this is more about technique than anything else, based on the ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

Understanding padding and fseek()

While we think of an image as pixels and lines, i.e., a two dimensional array like a checkerboard, the data is stored in the file as a single linear string of data. Adding the padding all at once ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

CS50 Pset4 Resize - Vertical Sizing

Have you looked at the raw image data using xxd? The image data for anything larger than n=1 is far too much! The code is using the output file's biHeight and biWidth to control reading the input ...
Cliff B's user avatar
  • 68.8k
1 vote
Accepted

pset 4: resize adding in black pixels

fseek(inptr, bf.bfOffBits + ((oldWidth * 3) * i) + newPadding, SEEK_SET); You want to go to the start of i line of infile. Each infile line is (oldWidth * 3 + oldPadding) bytes. Multiply it by i and ...
obesman's user avatar
  • 1,139
1 vote
Accepted

pset4 resize.c : output matches staff's but colour of square is always grey/white!

Please note that biHeight_original = bi.biHeight are both negative. So you do not do a single iteration, as i < biHeight_original is false.
obesman's user avatar
  • 1,139
1 vote

determine padding for scanlines in copy.c

It's not needed for a padding of 1, 2, or 3 bytes. But imagine what happened if bi.biWidth were a multiple of 4. bi.biWidth * sizeof(RGBTRIPLE) would be a multiple of 4. (bi.biWidth * sizeof(...
Blauelf's user avatar
  • 20.9k
1 vote

Pset 4 Resize makes a very colorful picture (not green!)--padding problem?

You change bi.biWidth and bi.biHeight to new scale using bi.biWidth = bi.biWidth * enlarge; bi.biHeight = bi.biHeight * enlarge; and then use code that relies on the values to represent the ...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

pset4, copy.c padding

Yes, the fseek and padding loop are absolutely necessary. Think about it mathematically. The image portion is composed of 36 bytes (3 lines with 3 3-byte pixels per line plus 3 bytes of padding per ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Issues with padding - why am I getting a black image for every outfile?

You should run the staff's version for a couple of files and different values of resize and then run peek on those files to see which are the headers that actually change. Also, take a closer look ...
Irene's user avatar
  • 1,687
1 vote
Accepted

PSET4 Resize: image resizes but fails check50 (PADDING or HEADER???)

You'll see what your problem is if you do this: Think about it for a while and come back here again if this doesn't make it click for you... and I can add other tips.
Yuri Laguardia's user avatar
1 vote
Accepted

pset4 resize fseek() - non proper work

You could use fseek(inptr, -bi.biWidth * sizeof(RGBTRIPLE), SEEK_CUR); (no padding, as you never read some) to go back to the start of the line where you fseek at the moment, and after that loop, ...
Blauelf's user avatar
  • 20.9k
1 vote

Why does copy.c skip padding?

This is a late answer but is relevant as I feel that the actual question was not answered. I had the same question and while searching for answer reached this post."why is copy.c skipping over padding?...
Ravi 's user avatar
  • 11

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