Table of Contents

Corning Community College

ENGR1050 C for Engineers

Project: IMAGE PROCESSING - CIRCLE OF SQUARES (cos0)

Objective

To apply our existing knowledge of programming constructs in the application of a specific end result: a program that utilizes an image processing library to produce an image of a circle, constructed of squares.

Prerequisites/Corequisites

In addition to the new skills required on previous projects, to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

Background

We've spent our time so far this semester covering the basic concepts of programming, in C. Variables, selection statements, iteration, functions, structs, etc.

Now that we've gotten through a good deal of them, it is time to start applying those concepts so that deeper and further familiarity can be gained. This project is one such attempt at that.

We all know what a circle is, and in various math classes we've even explored various methods for doing things with circles (they have a radius, a circumference, a diameter), but how would we enable the computer to draw a circle?

One piece of that, obviously, is the math.

Another aspect of that is the programmatic piece. A circle implies something visual. On the computer that means an image.

So: we are going to use the gd image processing library to aid us in generating the image.

Program

Your task is to write a program that generates an image (PNG file), that is placed in your lab46 webspace (~/public_html/cos0/) for viewing, that does the following:

Now, gd has functions for drawing circles. You are NOT to use them for this project. As I said, this is a circle of squares. As such, you will be making use of the gdImageFilledRectangle() function.

Grabbing project resources

I have prepared a grabit for resources related to this project. To obtain:

lab46:~/src/c4eng$ grabit c4eng cos0
make: Entering directory '/var/public/fall2019/c4eng/cos0'
'/var/public/fall2019/c4eng/cos0/Makefile' -> '/home/wedge/src/c4eng/cos0/Makefile'
'/var/public/fall2019/c4eng/cos0/cos0.c' -> '/home/wedge/src/c4eng/cos0/cos0.c'
make: Leaving directory '/var/public/fall2019/c4eng/cos0'
lab46:~/src/c4eng$ 

At which point you can change into the newly created and populated cos0 directory.

How to view your image

When you have a functioning project and want to view the images generated, you need to make sure they are deployed into your public_html/ directory.

To view your image in a web browser, simply point it at the following URL:

… where “USERNAME” is your lab46 username (in lowercase), “DIRECTORY” will be the name of the project ('cos0'), and “IMAGE” is the name of your png file (likely also in lowercase, such as 'cos0.png').

Note that the tilde just prior to your username in the URL is critical and necessary.

And, of course, your basic compile and clean-up operations:

Just another “nice thing” we deserve.

NOTE: You do NOT want to do this on a populated cos0 project directory– it will overwrite files. Only do this on an empty directory.

Submission

To successfully complete this project, the following criteria must be met:

To submit this program to me using the submit tool, run the following command at your lab46 prompt:

$ submit c4eng cos0 cos0.c
Submitting c4eng project "cos0":
    -> cos0.c(OK)

SUCCESSFULLY SUBMITTED

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

What I'll be looking for:

78:cos0:final tally of results (78/78)
*:cos0:proper error checking and status reporting performed [13/13]
*:cos0:correct variable types and name lengths used [13/13]
*:cos0:proper output formatting per specifications [13/13]
*:cos0:runtime tests of submitted program succeed [13/13]
*:cos0:no negative compiler messages for program [13/13]
*:cos0:code is pushed to lab46 repository [13/13]

Additionally: