0

I'm currently working on resize, and for some reason the pixels in each row (except for one, the middle white one) seem to get resized horizontally except that with the resized pixel its a different color. Also, that resized pixel changes color with each running of the code for some reason. (See attached pictures (scale value used was 2)). But when I use a scale value of 1, the code works as it should (copies). Heres my code: https://gist.github.com/AProgrammerZ/bf2035932d7d636dc654663f4c3efe28 picture1 picture2

1

I've just started this one today and am currently struggling with vertical resize. I found answer from few years ago that should be helpful:

When writing the rgb triple, unfortunately you can't just say, "write it *4 times". C isn't that smart. It writes it once and then fills the other 3 times with garbage values or unknown values...which is why your colors are strange.

To resize, pseudocode below:

//iterate over infile scanlines for loop //for loop for vertical resize
//if this isn't the first time through this row to resize vertically //use fseek to reset the cursor back to the start of the row //for loop for horizontal resize //read a single RGB triple in //for loop to write that triple n number of times //add new padding //skip old padding

1
  • This seems like the right answer for what I've been experiencing as well (color being off). But I'm having a hard time following the pseudocode. Is there a way to simplify the answer? Oct 31 '19 at 2:11

You must log in to answer this question.

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