Comp 2673 Spring 2003 Lab 1
Comp 2673
Spring 2003
Lab 1
This lab will give you a chance to log on to the CS Sun machines,
and also to create some bitmap files. For those of you who have not used
a UNIX operating system before, this is your first introduction.
- Log onto the Sun machines.
- Create a directory for this lab, and change to that directory.
(Use the
mkdir
command and the cd
command.)
- Download the files testbmp.cpp
bmp.cpp, and
bmp.h. (Right click, and select "Save link as".)
- Compile by either creating a makefile to do the compilation, or by
typing the following at the prompt:
g++ bmp.cpp testbmp.cpp -o testbmp
The function main
in testbmp.cpp creates and stores values
in 2-D array to create an image that is a gray square. The file bmp.cpp
contains code for the function write_bitmap_file
. This
function takes a string (the file name), the width of the array, the
height of the array, and a pointer to the array as parameters. It creates
a bitmap file containing the image stored in the array. You do not
need to read and understand this code (unless you choose to). Make sure
you completely understand the code in the file testbmp.cpp
- Run the program (by typing its name,
testbmp
).
- Check that the file gray.bmp was created (use the
ls
command.)
- View the file using the program xv. Type
xv gray.bmp
at
the prompt.
- Modify the code in testbmp.cpp to create an image that is 200 pixels
tall and 400
pixels wide, and is white except for a 100 pixel tall and 50 pixel wide
block of black in the lower right-hand corner. Save this file as
blackandwhite.bmp.
- Modify the code in testbmp.cpp to create an image that is 100 by 100,
has an overall grey level of 100, and has black lines along both diagonals.
Save this file as blackX.bmp
- Create an image that is 100x100 white pixels, and has 3000 gray or
black or pixels, whose locations are randomly chosen within the square,
and whose gray level is randomly chosen from 0 to 255.
- Print these images and turn them in.
- Log out.