Help Please. creating an image in cpp

Hello, I am totally stuck, could someone please help me :) Here are my teacher instructors. Anything helps.

Structs in Arrays - Create an Image

As demonstrated in class.

You will create a 2D array of struct. The contents of the struct will be of unsigned char type and will represent the red, green, and blue pixel components. The objective is to write USM in gold on a black background.

RGB for black is < 0, 0, 0 >, while RGB for USM gold is < 255, 179, 0 >. Your image size will be 300 rows by 600 columns. This will be important in proportioning letters and in setting up two types of .ppm file.

Your .ppm file headers (the first three lines) will look like this:

P3
600 300
255

and:

P6
600 300
255

These will be included in your functions that write the two files from the array. To populate the array with values, you should set the entire array to black, then overwrite the appropriate values with USM Gold.

Important Measurements:

50 pixel border

25 pixel line width

U begins on 50 and ends on 200

S begins on 225 and ends on 350

M begins on 375 and ends on 550

To create the diagonals in M, the vertical distance is 50 to 200 and you should add or subtract static_cast<int>(row/2) from col in your col loop to vary the colored area horizontally and vertically.

Overall I found it useful to call a create array function and two write file functions from main.

A portable pixmap image file viewer.
http://fileinfo.com/extension/ppm




Here's my code:(start up on what I could think I would need.)
unsigned char pic [300][600];
int row=300;
int col=600;
for (int i=1; i<row +1;i++)
for (int j=1; j<col+1; j++);

for (int i=0; i<row;i++ );
for (int j=0; pic(0,0,0);
Last edited on
Topic archived. No new replies allowed.