May I please get help on this project in C++ I need to use the code displayed bottom of the
screen. Ive been trying to code it but it's been tough. we need to use prototype function and call
them up on the top of the main then call them inside. please help me out with thi so I can study.
Thank you.
project:
C++ code given in class:
#include
#include
using namespace std;
//initialize top half of the image with a white background
void initializeTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr);
//initialize bottom half of the image with a white background
vector>> initializeBottomHalf(const int maxc, const int maxr);
//Fill top half with the characters CSCE
void fillTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr);
//Fill bottom half with the characters UNT
void fillBottomHalf(vector>>& vec, const int maxc, const int maxr);
//Write top half to image file
void writeTopHalf(ofstream& fout, uint8_t arr[][maxr][3], const int maxc, const int maxr);
//Fill bottom half with the characters UNT
void writeBottomHalf(ofstream& fout, vector>>& vec, const int maxc, const int
maxr);
int main() {
const int MAXR = 480, MAXC = 640;
uint8_t colors[MAXR][MAXC][3];
for(int i = 0; i< MAXR; i++) {
for(int j = 0; j < MAXC; j++) {
colors[i][j][0] = static_cast(255);
colors[i][j][1] = static_cast(255);
colors[i][j][2] = static_cast(255);
}
}
for(int i = 40; i <= 440; i++) {
for(int j = 10; j <= 60; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
for(int i = 390; i <= 440; i++) {
for(int j = 10; j <= 210; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
for(int i = 40; i <= 440; i++) {
for(int j = 160; j <= 210; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Horizontal part of T
for(int i = 40; i <= 90; i++) {
for(int j = 430; j <= 630; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Vertical part of T
for(int i = 40; i <= 440; i++) {
for(int j = 505; j <= 555; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Right vertical leg of N
for(int i = 40; i <= 440; i++) {
for(int j = 370; j <= 420; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Left vertical leg of N
for(int i = 40; i <= 440; i++) {
for(int j = 220; j <= 270; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Diagonal part of N
for(int i = 40; i <= 440; i++) {
int jm = (i-40)/2+220;
int jb = max(220, jm-25);
int je = min(420, jm+25);
for(int j = jb; j <= je; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
ofstream fout("unt.ppm");
fout << "P3" << endl;
fout << MAXC << ' ' << MAXR << endl;
fout << 255 << endl;
for(int i=0; i < MAXR; i++) {
for(int j = 0; j < MAXC; j++) {
fout << static_cast(colors[i][j][0]) << ' ' <<
static_cast(colors[i][j][1]) << ' ' << static_cast(colors[i][j][2]) <<
' ';
}
fout << endl;
}
fout.close();
return 0;
}
//initialize top half of the image with a white background
void initializeTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr)
{
// insert code
}
//initialize bottom half of the image with a whi.
May I please get help on this project in C++ I need to use the code .pdf
1. May I please get help on this project in C++ I need to use the code displayed bottom of the
screen. Ive been trying to code it but it's been tough. we need to use prototype function and call
them up on the top of the main then call them inside. please help me out with thi so I can study.
Thank you.
project:
C++ code given in class:
#include
#include
using namespace std;
//initialize top half of the image with a white background
void initializeTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr);
//initialize bottom half of the image with a white background
vector>> initializeBottomHalf(const int maxc, const int maxr);
//Fill top half with the characters CSCE
void fillTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr);
//Fill bottom half with the characters UNT
void fillBottomHalf(vector>>& vec, const int maxc, const int maxr);
//Write top half to image file
void writeTopHalf(ofstream& fout, uint8_t arr[][maxr][3], const int maxc, const int maxr);
//Fill bottom half with the characters UNT
void writeBottomHalf(ofstream& fout, vector>>& vec, const int maxc, const int
maxr);
int main() {
const int MAXR = 480, MAXC = 640;
uint8_t colors[MAXR][MAXC][3];
for(int i = 0; i< MAXR; i++) {
for(int j = 0; j < MAXC; j++) {
colors[i][j][0] = static_cast(255);
colors[i][j][1] = static_cast(255);
colors[i][j][2] = static_cast(255);
}
}
for(int i = 40; i <= 440; i++) {
for(int j = 10; j <= 60; j++) {
2. colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
for(int i = 390; i <= 440; i++) {
for(int j = 10; j <= 210; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
for(int i = 40; i <= 440; i++) {
for(int j = 160; j <= 210; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Horizontal part of T
for(int i = 40; i <= 90; i++) {
for(int j = 430; j <= 630; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Vertical part of T
for(int i = 40; i <= 440; i++) {
for(int j = 505; j <= 555; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Right vertical leg of N
for(int i = 40; i <= 440; i++) {
for(int j = 370; j <= 420; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
3. }
//Left vertical leg of N
for(int i = 40; i <= 440; i++) {
for(int j = 220; j <= 270; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
//Diagonal part of N
for(int i = 40; i <= 440; i++) {
int jm = (i-40)/2+220;
int jb = max(220, jm-25);
int je = min(420, jm+25);
for(int j = jb; j <= je; j++) {
colors[i][j][0] = 0;
colors[i][j][2] = 0;
}
}
ofstream fout("unt.ppm");
fout << "P3" << endl;
fout << MAXC << ' ' << MAXR << endl;
fout << 255 << endl;
for(int i=0; i < MAXR; i++) {
for(int j = 0; j < MAXC; j++) {
fout << static_cast(colors[i][j][0]) << ' ' <<
static_cast(colors[i][j][1]) << ' ' << static_cast(colors[i][j][2]) <<
' ';
}
fout << endl;
}
fout.close();
return 0;
}
//initialize top half of the image with a white background
void initializeTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr)
{
4. // insert code
}
//initialize bottom half of the image with a white background
vector>> initializeBottomHalf(const int maxc, const int maxr)
{
// insert code
}
//Fill top half with the characters CSCE
void fillTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr)
{
// insert code
}
//Fill bottom half with the characters UNT
void fillBottomHalf(vector>>& vec, const int maxc, const int maxr)
{
//insert code
}
//Write top half to image file
void writeTopHalf(ofstream& fout, uint8_t arr[][maxr][3], const int maxc, const int maxr)
{
// insert code
}
//Fill bottom half with the characters UNT
void writeBottomHalf(ofstream& fout, vector>>& vec, const int maxc, const int
maxr)
{
// insert code
}
The purpose of this project is to write C++ programs using arrays and vectors where functions
are used to initialize them, modify them and write them to a file. We discussed in class how to
create a ppm image using a three-dimensional array of type uint8_t. Our image displayed the
characters UNT in green color with a white background. The image size was 640320 pixels. In
this project you will create a similar image of size 640320 pixels where 640 is the width and 320
is the height in pixels. In the top half of the image you will display CSCE and in the bottom half
of the image you will display UNT. Center each text in their respective half horizontally. The
5. vertical spacing between characters should be 10 pixels and the vertical spacing from characters
to the top and bottom edges of the image as well as to the horizontal line in the center of the
image should be 10 pixels. The horizontal spacing between the left and right edges and the top
line of characters should be 10 pixels. The horizontal spacing between the left and right edges
and the bottom line of characters should be at least 10 pixels. The horizontal spacing between
characters should be 10 pixels. All the above specifications mean that the height of each
character would be 140 pixels. The top line of characters would be vertically centered on row 70
and the bottom line of characters would be vertically centered on row 230. You can choose the
width of each character while making sure that the horizontal spacing between characters is 10
pixels. Color each character randomly. Use the same random color for every pixel in a character.
Use a three-dimensional array for handling the top half of the image. Use a three-dimensional
vector for handling the bottom half of the image. The following function prototypes should be
used and the corresponding functions be defined and called from main. //initialize top half of the
image with a white background void initializeTopHalf(uint8_t arr[][maxr][3], const int maxc,
const int maxr); //initialize bottom half of the image with a white background vector>>
initializeBottomHalf(const int maxc, const int maxr); //Fill top half with the characters CSCE
void fillTopHalf(uint8_t arr[][maxr][3], const int maxc, const int maxr); //Fill bottom half with
the characters UNT void fillBottomHalf(vector>>& vec, const int maxc, const int maxr); //Write
top half to image file void writeTopHalf(ofstream& fout, uint8_t arr[][maxr][3], const int maxc,
const int maxr); //Fill bottom half with the characters UNT void writeBottomHalf(ofstream&
fout, vector < vector < vector < uint_8>>>& vec, const int maxc, const int maxr);