Lab machines

We will be grading the MPs for this course using the EWS Linux machines. Any errors that you run into as a result of developing your code on other machines are your own responsibility.

No SVN

If you do not have an account on the svn server, you can still work on this MP by downloading the source files from mp1.tar.gz.

Goals and Overview

In this MP (machine problem) you will:

In addition, you’ll get more chance to mess with some of the things in C++ identical to those in Java — namely loops and conditionals — so that you can see for yourself that they work the same way.

The Assignment, Part 1: Reading and Understanding the Policies

Read and understand the following information:

Important Information

The information in these links is relevant to not just this MP, but every future MP as well, and you will be held responsible for having read and understood all of the information. So, part of this MP assignment is to read over this part 1 material, and to gain a complete understanding of it before moving on to part 2 of this assignment. This means that you should ASK QUESTIONS ON ANY OF THIS PART 1 MATERIAL THAT YOU DO NOT UNDERSTAND.

The Assignment, Part 2: Tutorials

Linux Environment

If you have not read through and/or watched the material we have on Linux and Vim, and are generally not comfortable with either, please go to the Resources page and review those tutorials.

SVN Reference

If you have not already done so, please review the SVN Reference. We will be using SVN as our source code control mechanism throughout the course.

The Assignment, Part 3: Coding

This portion of the MP has two requirements. You will first define a pixel class called RGBAPixel that is used by the PNG class to store the data associated with the pixels in an image. In addition you will write a bit of client code that modifies a PNG.

Checking Out the Code

Follow the instructions on the Course Setup page to checkout the code.

Once you’ve checked out the code, you should have (in your cs225 directory) a directory called mp1 containing the following:

Loading Clang

If you’re on EWS and didn’t follow the Setup the compiler step, do so now.

Background: Compiling and the Makefile

Go through the Makefile Tutorial before you begin the assignment, to familiarize yourself with the idea of Makefiles and how to use them. You will need to write a Makefile for both this assignment and several future assignments.

Make sure you check out your Subversion directory before doing the Makefile Tutorial.

Background: PNG image handling

In this assignment, you will be loading and saving images stored in the PNG image file format. You won’t need to know the details of how an PNG image is stored in a file; instead, you will rely on the EasyPNG code that we have provided for you. A reference for it is provided for you in Doxygen form.

Please read the Doxygen documentation. It will explain what functions are available for you to use for this MP.

If you still have questions about how to use EasyPNG, post on Piazza or ask course staff after you’ve read the Doxygen documentation.

Problem statement

  1. Create a class called RGBAPixel whose functionality is described in this Doxygen documentation. Take care to note that all the members of the class are public. Following convention, the class definition should be placed in a file called rgbapixel.h, and the member function implementations should be placed in a file called rgbapixel.cpp.

  2. Write a program (the function main), contained in file main.cpp, that uses the functions from the EasyPNG library to open a bitmap image named in.png, rotate the image by 180 degrees, and write the resulting image to the file out.png. You should assume that in.png is located in the working directory (i.e., the directory from which your program was run) and place out.png there as well. The output image should have the exact same dimensions as the input image (i.e. the two images should be of the exact same width and height). You may use the given files in_01.png, out_01.png, in_02.png, out_02.png, in_03.png, and out_03.png to test your program. First, copy in_01.png to in.png by typing

    cp in_01.png in.png
    

    at the command line on a lab system. Once your program has run, type

    diff out.png out_01.png
    

    to compare your program’s output to out_01.png, which is the output file produced by the solution program written by the course staff. If both files are the same, your program is likely running correctly. You may test your program a second time on the other pairs of images in the same manner. Your program will be graded using a similar procedure on a series of other bitmap images. Although we don’t provide you with these images, you are welcome to test your program on additional images of your own, looking at each output image to see whether it is a perfect 180 degree rotation of the corresponding input image.

Compilation

You need to write your own Makefile for this MP, and hand it in with your code:

Clang

We are using Clang as our compiler / linker this semester and libc++ as our standard library. See the Makefile Tutorial or the lab_intro Makefile for what compiler / linker flags you need.

Output Formatting Issues

We have provided your output format in the MP specification above, and you need to match that exactly. Testing will be done by comparing your output PNG image file to our own (using the diff utility). If your image file does not match ours, that is considered incorrect output; you do not get partial credit for getting close. So we recommend you use the tools you learned in part 1 of this MP. Furthermore, it is advisable to confine yourself to the use of the EasyPNG library functions listed above when manipulating images, just to be safe; just because two images look the same doesn’t mean they really are.

Implementation Notes

Handing in your code

To facilitate anonymous grading, do not include any personally-identifiable information (like your name, your UIN, or your NetID) in any of your source files. Instead, before you hand in this assignment, create a file called partners.txt that contains only the NetIDs of people in your collaboration group (if it exists), one per line. If you worked alone, include only your own NetID in this file. We will be automatically processing this information, so do not include anything else in the file. (If we must manually correct your submission, you may lose points.) As always, if you’re working in a group, each group member must hand in the assignment. (Failure to cite collaborators violates our academic integrity policy; we will be aggressively pursuing such violators.)

We will be using Subversion as our hand-in system this semester. Our grading system will checkout your most recent (pre-deadline) commit for grading. Therefore, to hand in your code, all you have to do is commit it to your Subversion repository.

Be sure your working directory is the mp1 folder that was created when you checked out the code. To hand in your code, you first need to add the new files you created to the working copy of your repository by typing:

svn add rgbapixel.h
svn add rgbapixel.cpp
svn add main.cpp
svn add Makefile
svn add partners.txt

To commit your changes to the repository type:

svn ci -m "mp1 submission"

The ci command tells SVN that you want to commit your changes to the repository.

The -m flag tells SVN that the quoted message following it will be a description of the changes you made. This is not a requirement, but it is a good practice to add comments to your revisions. In the event of needing to revert to previous revision, the comments will help you differentiate between the revisions (and in group projects, it can help identify who made the changes).

Grading Information

The following files are used to grade mp1:

All other files will not be used for grading.

Video FAQ

Good luck!