Chat with us, powered by LiveChat Gain more experience with dynamic memory allocation and deallocation. | WriteDen

Gain more experience with dynamic memory allocation and deallocation.

Through this programming assignment, you will learn to do the following:

  1. Learn to read and write binary files.
  2. Gain more experience with using pointers.
  3. Gain more experience with dynamic memory allocation and deallocation.

In this assignment, you are asked to manipulate an image from a 24-bit uncompressed bmp file. (The format of bmp files is given in http://en.wikipedia.org/wiki/BMP_file_format). To help with reading and writing the image file, you are given library functions and an example that deal with the bmp file (in a zip file). In the example, the image is flipped horizontally. You are asked to implement some additional functions including the verticalflip(), enlarge() and rotate() functions: the first flips the image vertically, the second is used to enlarge the image by an integer scale factor of 2 or 3; the last one is used to rotate the image either clockwise or counter-clockwise by a multiple of 90 degrees.

The program should take the following command-line options:

% bmptool [-f | -r degrees |-s scale| -v ] [-o output_file] [input_file]

Where -s means to scale the image by a scale factor of 2 or 3 as indicated on the command line with a 2 or a 3, -r means to rotate the image by a multiple of 90 degrees clockwise if positive or counter-clockwise if negative, -v means to flip the image vertically and -f means to flip the image horizontally. You can assume for each type (-s, -r, -f, or -v), the command line has at most one option, but that should not affect your code. Only implement each one one time no matter how many times it is included. However, the user may present a combination, say, ‘bmptool -r -s -f -v’. If multiple option types are present, the order for processing the image is that you do scale first, then rotate, and then flip vertically and finally flip horizontally.

You are required to use getopt() to process the command-line. If ‘-o output_file’ is missing, use standard output. If ‘input_file’ is missing, use standard input. The options to use standard input or standard output will only be used when chaining commands. Make sure the program returns 0 on success. In that case, one can ‘chain’ the commands using pipes, like:

% bmptool -s 2 1.bmp | bmptool -r 90 | bmptool -f -o 2.bmp

Your program needs to provide necessary sanity-check for command line arguments and handle various error conditions and prompt the user with helpful information. You need to use getopt() to process the command line arguments. Test your program with various combinations to make sure it works as expected. You must use dynamic memory to store the content of the new image before writing out to file. You need to reclaim memory afterwards to prevent memory leaks. Include your source code, your Makefile, the bmplib files that I have provided, and the example.bmp file in the zip file. I should be able to create the executable by typing ‘make’. The Makefile should also contain a ‘clean’ target for cleaning up the directory (removing all object files). Make sure you don’t include intermediate files: *.o, executables, *~, etc., in your submission. Please make sure you submit homework before the deadline. There will be a late penalty as per the syllabus.

If the program does not compile and do something useful when it runs it will not count.

HOW OUR WEBSITE WORKS

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of 
HIGH QUALITY & PLAGIARISM FREE.

Step 1

To make an Order you only need to click ORDER NOW and we will direct you to our Order Page at WriteDen. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
 Deadline range from 6 hours to 30 days.

Step 2

Once done with writing your paper we will upload it to your account on our website and also forward a copy to your email.

Step 3
Upon receiving your paper, review it and if any changes are needed contact us immediately. We offer unlimited revisions at no extra cost.

Is it Safe to use our services?
We never resell papers on this site. Meaning after your purchase you will get an original copy of your assignment and you have all the rights to use the paper.

Discounts

Our price ranges from $8-$14 per page. If you are short of Budget, contact our Live Support for a Discount Code. All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Please note we do not have prewritten answers. We need some time to prepare a perfect essay for you.