Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Pseudo code for resize.c
- * Program to enlarge a BMP image by factor of n (number passed in as argument to program when running it).
- * begin main
- * if argc is not equal to 4
- * print out message for correct usage
- * return 1 for error
- * end if
- * store filename of input file (argv[2]) in variable of type char *
- * store filename of output file (argv[3]) in another variable of type char *
- * create a variable of type int and store in it the return value of atoi() with
- * argv[1] passed into it (this is the number, n, which will be used as the factor to resize the image by).
- * if the value of n is not between 1 and 100 (inclusive)
- * print out an error message
- * return 2 for error
- * end if
- * declare file pointer variable and store the name of the input file in it, and try to open file for reading
- * if the file couldn't be opened (and file pointer is NULL)
- * print out error message
- * return 3 for error
- * end if
- * try to open the output file for writing, declared as a file pointer variable
- * if the file couldn't be opened (and file pointer is NULL)
- * print out error message
- * return 4 for error
- * read input file's BITMAPFILEHEADER, after declaring a variable of type BITMAPFILEHEADER
- * read input file's BITMAPINFOHEADER, after declaring a variable of type BITMAPINFOHEADER
- * if BMP file is not a 24-bit uncompressed BMP 4.0 (likely)
- * close input file
- * close outtput file
- * print error message
- * return 4 for error
- * end if
- * remember the input file's padding, storing it an integer variable named padding (be sure to calculate it correctly)
- * remember original image's dimensions as integer variables img_width and img_height
- * calculate resized image's dimensions by multiplying original by factor of n
- * calculate resized image's padding
- * update the header info for the resized image, calculating the new bfSize and biSizeImage
- * write outfiles BITMAPFILEHEADER and BITMAPINFOHEADER using fwrite
- * iterate over input file's scanlines in a for loop, going from 0 until the height of the original image - 1
- * iterate over pixels in scanline in an inner for loop, going from 0 to the width of the orignal image - 1 to resize horizontally
- * declare RGBTRIPLE variabl for temporary storage
- * read into storage from input file
- * for 0 to n - 1 times
- * write into output file the RGBTRIPLE data, by as many bytes as RGBTRIPLE, one byte on each iteration
- * end for
- * for 0 to output file scanline padding
- * put in a 0 for the padding
- * end for
- * skip over input file padding
- * for 0 to original image width, iterate over the image's width to resize vertically
- * create another temporary storage place RGBTRIPLEs
- * read triples data from input file and store it
- * for 0 to as many times as the original image's height
- * write into output file the RGBTRIPLE data, by as many bytes as RGBTRIPLE, one byte on each iteration
- * end for
- * end for
- * rewind cursor by size of the input file padding
- * end for
- * end for
- * close input file
- * close output file
- * return 0 for success
- * end main
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement