0

I've been struggling with resize coding for more than three weeks. Still cannot get the correct outfile. Instead it shows 'twisted image' as shown below (image viewer zoom fit). enter image description here

There must be something wrong with my padding or positioning. But I cannot pinpoint which line(s) are causing this. Headers have been confirmed right using the peek function. Related portion of my code is shown below. If anyone can help me out, I would very much appreciate it. enter image description here

2
  • Please paste your code here instead of a picture of your code. You can edit it, no need to make a new question.
    – Sam Gerber
    Sep 24 '15 at 3:57
  • I might have overlooked an important point. Let me come back after correcting it.
    – Yoshi Watt
    Sep 24 '15 at 4:26
0
  • Line 88 shouldn't need *sizeof(RGBTRIPLE), as you can see in an xxd output below, an image that's 3 pixels x 3 pixels is 3 rows tall and 3*sizeof(RGBTRIPLE)+padding bytes wide

    0000036: 00ff00 00ff00 00ff00 000000 ............
    0000042: 00ff00 ffffff 00ff00 000000 ............
    000004e: 00ff00 00ff00 00ff00 000000 ............

  • Line 98 will always return true, as your for loop's end condition is j

  • Line 103 should have k<biOrg.biWidth

  • Lines 121 through 125 need to be moved to between line 116 and 117. You need padding on every row. Where you have it now, you are only writing it to every m rows.

2
  • Sam, sorry for coming back late. The first bullet you raised is the one I mentioned in the comment to your first suggestion. You are right on bullet 2 and 3. On bullet 4, however, I took your suggestion 'line 121 and 122' as 'line 121 through 125', and moved the set between line 106 and 107. Then I got an outfile with upper portion twisted, the lower portion in black, and at the very bottom a kind of Christmas illumination of small red, green and blue lights. Then I put the set between line 115 and 116. I got the similar result. I'll keep on working on my own based on your suggestion.
    – Yoshi Watt
    Sep 26 '15 at 4:46
  • Yoshi, sorry, I totally messed up the line numbers somehow. You were right that I meant 121 through 125, but I meant to say to put them between 116 and 117, as this is the spot in your program when you have written the last pixel in a given row.
    – Sam Gerber
    Sep 26 '15 at 5:00

You must log in to answer this question.

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