Return to labs index
Assignment #4 - Image Manipulation)
Due: October 7th at 11:59PM(Thursday)

Files

Overview

This assignment asks you to manipulate the pixel array from a .bmp file. Specifically, you are asked to play with a 24-bit uncompressed .bmp image.

In order to keep the focus on manipulating arrays, points, and dynamic memory, you have been given libary functions that read in and write out the file. It should be noted that these will only work in little-endian machines, such as the intel-architecture unix.andrew maxhines. They will not work on big-endian machines, such as the iMacs.

You are given one example, the flip(), which flips the image and asked to implement the enlarge() and rotate() functions. Note that the rotate() function should rotate the image clockwise.

In addition to the library, itself, you are asked to implement a simple command-line tool that makes use of the library -- as well as a shell-script test driver that serves as a tool for validating your assignment.

Note: In this lab, it will require the use of malloc(). We will talk about this on Thursday, but for now, just use the example of flip and the man pages to understand how to use malloc. If you have questions, we are always here to help.

The Library

The details of the enlarge() and rotate method are contained in the comments within bmplib.c, as is the flip() example. You'll also want to pay careful attention to the pixel type defined within bmp.h.

The Command-Line Tool

Your main program should work as follows. It is important that it work exactly as follows, for example, it should take command-line arguments rather than be interactive.

bmptool enlarge {scale} | rotate {degrees} | flip inputfile.bmp outputfile.bmp

It should exit with a return value of 0 upon success and non-zero in the event of any problem.

The Test Driver

Do not blow off this requirement -- it counts a lot, maybe as much as the rest of the assignment. It is expected to take you more time than the C code, itself. Start early, you'll need to finish the C code in time to do this -- and it will take plenty of time

You are asked to implement a shell script that flips, enlarges, and/or rotates images from an input directory according to the command-line options. The resulting images should be stored in an output directory and should also be sanity-checked.

The syntax of the testdriver should be as follows:


Summary

testbmptool.sh -eS | -rD | -f {inputdir} {outputdir}

Arguments

-e - enlarge using the provided Scale
-r - rotate by the provided number of Degrees
-f - flip requires no arguments

{inputdir} is a directory containing one or more reference images. These images are transformed as specified as above.

{outputdir} is a directory into which the transformed output images should be placed.

At least one of -e, -r, and -f should be supplied. If more than one is supplied, they should be applied to the image in the order in which they are specified.

Operation and Function

For each file in the input directory, the test driver calls upon bmptool to transform the image as prescribed by the command-line arguments. The transformations can be specified in any order and should be applied in the same order. It is legal to repeat the same type of transformation more than once. The resulting output file should have the same name as the input file -- but it should be written into the user-specified output directory.

Exit Status

The test driver should sanity check the arguments to ensure that at least one transformation is specified and that the input and output directories are specified and exist. It should also ensure that the output files are non-zero in length. It should pay attention to the return value of the bmptool.

It should exit with a status of 0, unless a problem is discovered, in which case it should exit with a non-0 value. In the event of a problem with an individual instance, the test driver should continue -- but should ultimately report a non-0 exit code.


Special Restrictions

Make sure to name your final C files are called bmplib.c and bmptool.c and your tester file is called testbmptool.sh. Also note that those are the ONLY files you will be turning in. You should not change our headers, and you should not need any headers of your own. You will only submit those three files.

We're Here To Help!

As always -- remember, we're here to help!

Autograding Tests