manipulating records

I am having a hard time doing solving this question if someone can help me it would be great..

To blend the above two images, sort of like a cross-fade, we would, for each pixel in the parrot image, obtain its colour (as an R, G, B triple), obtain the colour of the pixel at the same position in the cat image (as another R, G, B triple), and then find the average of the two colours. If (r1, g1, b1) is the colour of the first pixel, and (r2, g2, b2) is the colour of the second pixel, then the average of those two colours is:

( (r1+r2)/2, (g1+g2)/2, (b1+b2)/2 ).

Lucky for you, you only have to worry about blending a single pair of colours, rather than a whole image!

Define a record type (i.e. a struct in C++) called Colour to store the red, green and blue values for one pixel. It's up to you to choose appropriate types for the members of your record.
Write a function called blend that takes two Colour records as parameters and returns a Colour record that is the average of the two colours.
Write a function called printColour that prints out the contents of a Colour record in a reasonable way that identifies which values are which. For example: if the Colour record contained the colour (0.5, 0.7 0.9) the function might print something like this:

R: 0.5, G: 0.7, B: 0.9
In your main() function, declare and initialize two Colour records with colour data of your choosing (remember: colour values should be between 0.0 and 1.0!). Use the blend function from step 2 to obtain the average of these two colours. Print out the two original colours and the blended colour using your function from step 3
What is your problem? The instructions are clear.

Define a record type (i.e. a struct in C++) called Colour to store the red, green and blue values for one pixel. It's up to you to choose appropriate types for the members of your record.


1
2
3
4
5
6
7

tydef struct
{
    float Red;
    float Green;
    float Blue;
}Colour;



Write a function called blend that takes two Colour records as parameters and returns a Colour record that is the average of the two colours.


Colour blend(Colour c1, Colour c2)
{
// your code here
}

Write a function called printColour that prints out the contents of a Colour record in a reasonable way that identifies which values are which.


1
2
3
4
5
6
void printColour (Colour colour)
{
   // your code here
}

Topic archived. No new replies allowed.