CS638 - Fall, 1999

Homework Assignment #3: Programming Warmup #2

Due before class, September 23, 1999

Last modified:

The goal of this programming assignment is to make sure everyone is able to use the programming tools that they need this semester. This time, we will do some graphics, but the goal is to see if you can use one of the graphics tools (a library to read images).

You must write a program that:

  1. Prompts the user for the name of a ".tif" file. Preferably, you should use an fltk file_chooser widget.
  2. Opens that file and displays it in a window.
  3. Responds to mouse clicks in the window in a way that shows you can tell where in the image the mouse was clicked. Printing out the mouse position (e.g. so that if the user clicks in the upper left corner of the image it will say 0,0) is the most trivial thing to do.
  4. Prompts the user for a file name and writes a tif file.

Once again, we are more concerned that you figure out how to use the programming tools (fltk, Visual Studio, libtiff), than you actually do a program that does something interesting. Of course, if you want to write a program that does something cool, we'd appreciate it. It just won't get you any extra points for your grade.

In addition to writing a program that reads and writes TIFF, you must also learn a little bit about a program that can help you make TIFF pictures. In the CS envronment, we provide a program called PaintShopPro. Any painting program (Photoshop, Paintshop, Canvas, GIMP, ...) is OK.

You must use this program to make a picture in TIFF format. Any picture that has your name in it will be fine.

Handing things in:

Each student will get a handin directory. The handin directory will be ~cs638-2/handin/hw3/LOGIN (or p:\couse\cs638-gleicher\handin\hw3\LOGIN on NT) with your cs login in the place of LOGIN.

If you look in the handin\hw3 directory and don't see a directory for yourself, send email to Richard (yugu@cs.wisc.edu). Note: there will may be a delay between your request and when he can make the directory for you, so please ask before Tuesday.

Do not work in the handin directory. Copy your files there once the program is working. (there won't be enough disk space for everyone to put all of their working files in the handin directory).

You should only copy the following files into the directory:

In short, we need all the files necesary to build your program (and a readme file). We do not want the executable, the debugging information, the .obj files, ...

Also, you need to configure things so they will compile in the CS environment. If you build your programs at home or somewhere besides a CS machine, you will probably need to change your project settings.

If you need help...

One good source of hints is Richard's "DrawBox" example program which displays a tiff image in an fltk window.

I have also placed some examples on the Example Code Page.

How this assignment will be graded:

Basically, our concern is that you can turn in a program that handles images. We will check to see that your program does work, and look at it to make sure we can understand what it does.

FAQ and Hints:

LibTiff problems:
Some people (including me) have notice some strange behavior from the libtiff library. Specifically, programs crash when run in the debugger, but not when they are run outside the debugger. It gives an "invalid handle" error when trying to close the tiff file.
We are trying to resolve this problem. Richard (who built and tested the library) has not experienced the problem, which is making it more difficult to resolve.
SOLUTION: this problem is caused by an incorrect thing we did when building the library. We will post a newer version of the library. Until then, either don't use the debugger, or don't close your file.
LibTiff gives me warnings if I create the image in photoshop, paintshop, ...
Usually, things work fine even if you get these warnings. They are just telling you that the program that created the file put additional information into the file that libtiff doesn't understand.
Minimal click behavior:
The absolute easiest thing to do to show that you've satisfied #3 is to simply print out the coordinate. Using printf is OK. (you can always move your image window to the side so you can see it).
Of course, you might want to try to do something more interesting, like changing the image around the mouse click or something.