This is in language C In this assignment, you will write a C program that involves processing 2-dimensional arrays. A two-dimensional array is often used to represent a picture (or an image). For simplicity, your program will process only black-and-white images. Each pixel in the image will be a single char. The only legal chars are the asterisk (‘*’) which represents the color black, and the blank space (‘ ’) which represents the color white. Your program must read the image from stdin. The format of the input file is as follows: the first line of the file will contain two integers followed immediately by a newline. These numbers represent the number of rows and columns in the image, respectively. These dimensions may be any positive int value (i.e., more than 1 digit is possible). Each succeeding line will contain one row of the image, followed by a newline char. For example, the input might be: 5 5 * * * * * * * * * * * * * * * * The size of the image will be at least 1x1. If the input file does not have this format, then your program should abort and return an exit status of 1. Note that any additional chars in the input file also constitute an invalid input file. Your C program can abort processing and return to the command line by executing the statement: exit(1); Your program will need to #include in order to access the exit function. Your program must implement the following image transformations.  invert: This transformation should change every ‘*’ into a blank character, and every blank character into a ‘*’  flip direction: This transformation should flip the image. If the direction is either ‘H’ or ‘h’, then the image should be flipped across an imaginary vertical line down the center of the image. This transformation is illustrated below for an image of the letter F. If the direction is either ‘V’ or ‘V’, then the image should be flipped across an imaginary horizontal line across the center of the image.   rotate degrees: This transformation should rotate the image clockwise the specified number of degrees. The only legal values for degrees are 90, 180 and 270.   stretch factor: This transformation should stretch the image horizontally by the given multiple.   The input image to your program must be read from the standard input (stdin), but the transformations to the image will be specified on the command line. You will invoke the program as follows: $ ./a.out list-of-desired-transformations < inputFileName The syntax for the list-of-desired-transformations is as follows:  rot – indicates a rotation, and must be followed by exactly 90, 180, or 270.  flip – indicates a flip, and must be followed by a single char, which must be V, v, H, or h  inv – indicates an inversion  stretch – indicates a stretch, and must be followed by a single integer value (such as, 2 or 15 or 345) For example, the program might be invoked as: $ ./a.out rot 90 flip H inv rot 180 stretch 3 flip V < inputFileName   Note that each entry on the command line is a string of a characters, such as “rot” or “90” or “3”. You can convert a string into an integer using the C library function atoi (ascii to integer), as shown below. int foobar = atoi ( argv[2] ); Your program should perform each of the given transformations, in the given order, and then output the resulting image to stdout. Do not output the image size to stdout. Do not output any intermediate results to stdout. Do not output any other information, such as a message saying “Your image now looks like:” If your program successfully transforms the image, then it should return an exit status of 0. If the command line arguments are in any way faulty, such as the spelling of the command is incorrect, or the rot is not followed by a legal number of degrees, or the flip is not followed by a legal direction, then your program should abort and return an exit status of 2. This exit status will only be returned if the format of the input file is valid. Notice that it is legal for the command line to contain zero transformations. In this case your program should simply output the original image.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is in language C

In this assignment, you will write a C program that involves processing 2-dimensional arrays.

A two-dimensional array is often used to represent a picture (or an image). For simplicity, your

program will process only black-and-white images. Each pixel in the image will be a single

char. The only legal chars are the asterisk (‘*’) which represents the color black, and the blank

space (‘ ’) which represents the color white.

Your program must read the image from stdin. The format of the input file is as follows: the

first line of the file will contain two integers followed immediately by a newline. These numbers

represent the number of rows and columns in the image, respectively. These dimensions may be

any positive int value (i.e., more than 1 digit is possible). Each succeeding line will contain one

row of the image, followed by a newline char. For example, the input might be:

5 5

* * * *

* * *

* * *

* * *

* * *

The size of the image will be at least 1x1. If the input file does not have this format, then your

program should abort and return an exit status of 1. Note that any additional chars in the input

file also constitute an invalid input file. Your C program can abort processing and return to the

command line by executing the statement:

exit(1);

Your program will need to #include <stdlib.h> in order to access the exit function.

Your program must implement the following image transformations.

 invert: This transformation should change every ‘*’ into a blank character, and every blank

character into a ‘*’

 flip direction: This transformation should flip the image. If the direction is either ‘H’ or

‘h’, then the image should be flipped across an imaginary vertical line down the center of the

image. This transformation is illustrated below for an image of the letter F. If the direction

is either ‘V’ or ‘V’, then the image should be flipped across an imaginary horizontal line

across the center of the image.

 

rotate degrees: This transformation should rotate the image clockwise the specified number of degrees. The only legal values for degrees are 90, 180 and 270.

 

stretch factor: This transformation should stretch the image horizontally by the given multiple.

 

The input image to your program must be read from the standard input (stdin), but the

transformations to the image will be specified on the command line. You will invoke the

program as follows:

$ ./a.out list-of-desired-transformations < inputFileName

The syntax for the list-of-desired-transformations is as follows:

 rot – indicates a rotation, and must be followed by exactly 90, 180, or 270.

 flip – indicates a flip, and must be followed by a single char, which must be V, v, H, or h

 inv – indicates an inversion

 stretch – indicates a stretch, and must be followed by a single integer value (such as, 2 or 15

or 345)

For example, the program might be invoked as:

$ ./a.out rot 90 flip H inv rot 180 stretch 3 flip V < inputFileName

 

Note that each entry on the command line is a string of a characters, such as “rot” or “90” or

“3”. You can convert a string into an integer using the C library function atoi (ascii to integer),

as shown below.

int foobar = atoi ( argv[2] );

Your program should perform each of the given transformations, in the given order, and then

output the resulting image to stdout. Do not output the image size to stdout. Do not output any

intermediate results to stdout. Do not output any other information, such as a message saying

“Your image now looks like:”

If your program successfully transforms the image, then it should return an exit status of 0.

If the command line arguments are in any way faulty, such as the spelling of the command is

incorrect, or the rot is not followed by a legal number of degrees, or the flip is not followed by a

legal direction, then your program should abort and return an exit status of 2. This exit status

will only be returned if the format of the input file is valid. Notice that it is legal for the

command line to contain zero transformations. In this case your program should simply output

the original image.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education