Question: Description For this assignment, you will write a C++ program called hw2 that deals with files in the new and improved Alpha format, as defined
Description
For this assignment, you will write a C++ program called hw2 that deals with files in the new and improved Alpha format, as defined below.
Alpha file format
Alpha is an image format, like GIF, JPEG, or PNG. Its certainly a primitive format, but, on the other hand, its easy to work with. Here is an example of a tiny Alpha file, five pixels wide and six pixels high, that looks like the letter J:
Alpha a* aaaza aaaza azaza azzza aa*
Here is another example, that represents the same image as the first:
Alpha # This shows us how # not to do it, but it should still work. A * aaaZa#hi there aaaza # @#$^*%& format! azaza # hello azZZA a a*
First six bytes of an Alpha file are: Alpha
After that, ignore all whitespace in a line, as defined by isspace.
Ignore any comment between a # and the end of the line, blank lines, and any line that is only a comment.
If an asterisk occurs at the end of a line, it means repeat this. Extend the line with the previous pixel in the line to make this line the same pixel length as all the other lines.
Everything else in the lines must be az or AZ.
Lowercase and uppercase letters are treated identically.
A is light, Z is dark.
All lines should contain the same number of pixels.
A 00 image is valid.
Program
You will write a program called hw2 that will read & write a number of Alpha files, possibly mirrored & rotated.
The programs arguments will be: transformation [file]
The mandatory single transformation is a number of degrees clockwise to rotate: 0, 90, 180, or 270. No other values are valid.
If the transformation argument ends with m (for mirror), then all images are flipped left-right before any rotation. For example, if the image is a face looking left, a transformation of 0mwould result in a face looking right.
After the mandatory single one-and-only-one transformation argument comes an optional series of filenames. For each file, read that image, mirror/rotate it, replace the file with the transformed image, sending nothing to standard output.
If no filenames are given, then read an image from standard input, mirror/rotate, and write to standard output.
Sample Runs
Here are several sample runs, where % is my prompt. What you type looks like this. Ignore the indentation.
% make g++ -Wall -Wextra -Wpedantic -c -o main.o main.cc g++ -Wall -Wextra -Wpedantic -o hw2 main.o % cat gamma Alpha abbbb vwxyz ccccc % ./hw2 0Debugging
If you encounter STACK FRAME LINK OVERFLOW, then try this:
export STACK_FRAME_LINK_OVERRIDE=0fd4-c07344cc860a40df1ec7bcedd1a7b466Requirements
You may not use C-style
or facilities, such as printf, scanf, fopen, and getchar. Instead, use C++ facilities such as cout, cerr, and ifstream.
Your output must be lowercase.
Your output may not contain any asterisks, spaces, tabs, comments, or blank lines.
Produce an error message and stop for:
a bad transformation argument
Produce an error message and go on to the next file for any file-specific error, including:
cant read or write a file
a $ is encountered where azAZ are expected
lines with differing number of pixels
asterisk at the start of a line, or where it would result in no characters or a negative number of characters.
all the lines end with asterisks
(I realize that, in a 00 image, all of the no lines end with asterisks. Still, 00 is valid.)
Any error message must go to standard error, include argv[0], and include the current filename, if approproiate.
The input image may be of any dimensions. There are no limits.
The output must end with a newline.
Newlines do not separate linesnewlines terminate lines.
No global variables.
Except for a single optional global string containing argv[0].
For readability, dont use ASCII int constants (65) instead of char constants ('A') for printable characters.
We will compile your program as shown above.
If that generates warnings, you will lose a point.
If that generates errors, you will lose all points.
There is no automated testing/pre-grading/re-grading.
Test your code yourself. Its your job.
Even if you only change it a little bit.
Even if all you do is add a comment.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
