Skip to main content
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
  • 69.3k
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
  • 21k
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
  • 21k
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
  • 21k
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
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
  • 69.3k
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
  • 69.3k
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
  • 69.3k
1 vote

pset4 padding calculation last %

If you don't have the outer % 4, the expression would evaluate to 4 bytes of padding for any multiples of 4. Adding 4 bytes of padding to a multiple of 4 isn't necessary. This is why you need the ...
elev8eng's user avatar
1 vote

pset4 padding calculation last %

The point is about bi.biWidth being a multiple of 4. In that case it's 4-0, but it should be 0.
Blauelf's user avatar
  • 21k
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
  • 21k
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
  • 21k
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

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