0

In pseudo code I'm basically doing this

for (height of start file)
    {
       //***1***
     for (length of resizing factor)
         {

          for (Width of start file)
              {
               scan pixels

               for(length of resizing factor)
                  {
                   write pixels to end file
                  }
              }

         skip over padding of start file

         for(length of padding in end file)
            {
             write padding to end file
            }
        }
      //***2***
   }

Now I know I need to reset the scannerthingamagigy in this process. I'm using fseek() to send it back , and the closest I can get to a correctly resized image is with putting that statement within the outermost (for).

If I put it at the beginning (at //1), I get an image that is shifted down by 1 row, with the top row being junk and the last row not appearing.

If I put it at the end of the outermost (for) loop (at //2) (which seems the most logical to me), I get an image that is shifted up by 1 row, with the bottom row being completely white (when testing with smiley.bmp).

The image is otherwise correct, just shifted by one row.

I've been looking d trying all sorts of stuff but can't seem to figure out a solution.

Any help is greatly appreciated.

Thank you!

7
  • Using fseek to go back to the beginning of the current row at //2 is the logical choice. However, if you're shifting the image, something subtle with your code is going on. In this case, pseudocode isn't going to work. You need to post actual code for analysis.
    – Cliff B
    Jul 16 '16 at 1:17
  • Is it possible that one of the variables in the file header being off would cause that?
    – Michael
    Jul 16 '16 at 1:37
  • Not likely. However, you can verify the headers are correct even if the image isn't being handled right. You can use a multiplier of 1 and compare the source file to the result file and they should be identical. For 2 or more, use the staff example of resize and run the same source file through yours and theirs and then compare the headers in the two result files.
    – Cliff B
    Jul 16 '16 at 1:51
  • Thanks for all your help. I tried it with a factor of 1 and the headers were the same. However, my file was really messed up. It looks like the first line of the input just gets written over and over again for the whole thing....interesting!
    – Michael
    Jul 16 '16 at 3:14
  • Sounds like the code goes back to the beginning of the current line, but fails to go forward after the current line is processed n times.
    – Cliff B
    Jul 16 '16 at 3:15
1

After reviewing actual code in chat, the problem came down to the placement of the fseek to go back to the beginning of the current line being processed, and knowing when not to backtrack.

Long chat, short answer. Glad you fixed it! ;-)

1
  • also I was creating the header variables a bit out of order and that was causing an issue.
    – Michael
    Jul 22 '16 at 4:22

You must log in to answer this question.

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