I did not bother to name this...

From Insensitive Agouti, 1 Month ago, written in C++, viewed 30 times.
URL http://codebin.org/view/ee012694 Embed
Download Paste or View Raw
  1.  
  2.     // determine padding for scanlines
  3.     int padding = (4 - (bio.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
  4.     int paddingnew = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
  5.  
  6.     // go over every line in the source file
  7.     float oh = factor;
  8.     for (int i = 0, biHeight = abs(bio.biHeight); i < biHeight; i++)
  9.     {
  10.         // this will print a line several times or skip it, depending on the factor
  11.         for (; oh > 0; oh--)
  12.         {
  13.             // go over every pixel in the source file
  14.             float ow = factor;
  15.             for (int j = 0; j < bio.biWidth; j++)
  16.             {
  17.                 // this will print a pixel several times or skip it, depending on the factor
  18.                 for (; ow > 0; ow--)
  19.                 {
  20.                     RGBTRIPLE triple;
  21.                     fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
  22.                     fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
  23.                     if (ow >= 1)
  24.                     {
  25.                         //reset input file cursor
  26.                         fseek (inptr, -sizeof(RGBTRIPLE), SEEK_CUR);
  27.                     }
  28.                 }
  29.                 // bring the remainder of ow + factor to the next pixel
  30.                 ow += factor;
  31.             }
  32.             // skip the old padding in input, print the new padding in output
  33.             fseek(inptr, padding, SEEK_CUR);
  34.             for (int k = 0; k < paddingnew; k++)
  35.             {
  36.                 fputc(0x00, outptr);
  37.             }
  38.             if (oh >= 1)
  39.                 {
  40.                     //reset input file cursor
  41.                     fseek (inptr, -bio.biWidth, SEEK_CUR);
  42.                 }
  43.         }
  44.         // bring the remainder of oh + factor to the next line
  45.         oh += factor;
  46.     }
  47.  
  48.     // close infile
  49.     fclose(inptr);
  50.  
  51.     // close outfile
  52.     fclose(outptr);
  53.  
  54.     // success
  55.     return 0;
  56. }

Reply to "I did not bother to name this..."

Here you can reply to the paste above