Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
- int oldPadding = (4 - (oldWidth * sizeof(RGBTRIPLE)) % 4) % 4;
- long inposit = ftell(inptr);
- long outposit = ftell(outptr);
- // iterate over infile's scanlines
- for(int i = 0; i < abs(oldHeight); i++)
- {
- //iterate over the scanlines n times
- for(int j = 0; j < n; j++)
- {
- //iterate over the pixels
- for(int k = 0; k < abs(oldWidth); k++)
- {
- //get temp var
- RGBTRIPLE triple;
- //store file position
- //inposit = ftell(inptr);
- //set the correct position to read from
- fseek(inptr, inposit, SEEK_SET);
- //read pixel into infile
- fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
- //store file position
- inposit = ftell(inptr);
- //set the correct position to write to
- fseek(outptr, outposit, SEEK_SET);
- //write n times to outfile
- for(int l = 0; l < n; l++)
- {
- fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
- }
- outposit = ftell(outptr);
- }
- // then add it back (to demonstrate how)
- for (int k = 0; k < padding; k++)
- {
- fputc(0x00, outptr);
- }
- //send outptr to the next line
- fseek(outptr, padding, SEEK_CUR);
- //return to start of line for reading
- fseek(inptr, 0 - oldWidth, SEEK_CUR);
- //update inposit and outposit
- //inposit = ftell(inptr);
- outposit = ftell(outptr);
- }
- //move input fileposition to the next line
- // skip over padding, if any
- fseek(inptr, oldWidth + oldPadding, SEEK_CUR);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement