I am following the pset3 walkthrough and currently at the point where I have to resize horizontally.


My approach is to currently rewrite the resized bi headers as bir (eg bir.biWidth = bi.biWidth * n),

then i use multiple for loops to iterate over the row n times.

This works in resizing horizontally for n = 1, and kind of works (ie correct number of green boxes) with n = 2 but it is quite weird ( http://tinyimg.io/i/DEOgxZ9.png ) and with further values of n, the issue of the grey and white boxes above just become exarcebated.

I would appreciate any assistance to point me in the correct direction, thank you!


Interesting. What makes you think that it's messed up or that you're not heading in the correct direction?

Well, correct direction other than top-down vs. bottom-up. ;-)

Have you forgotten that a negative value for biHeight tells the display software to paint the image from the bottom up????

Given that, with a resize of 2, the bottom half of the image will be the actual data that you've generated, while the top half of the image will be garbage. The garbage is printed because the header data still tells the system how much data to display, so it will still display that much data, even if it doesn't exist in the file. It'll grab it from somewhere, perhaps from the slack space at the end of the file. (It would also ignore excess data if there were too much.)

Now, all you need to do is add the vertical scaling code!

BTW, check your output header data.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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