Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the function opacify. This code is based on C0 Programming language. /* Task 4 - Respecting interfaces * * This implementation of the opacify()

Complete the function opacify. This code is based on C0 Programming language.

/* Task 4 - Respecting interfaces * * This implementation of the opacify() function takes a pixel and * return a pixel with alpha intensity 0xFF and with other intensities * unchanged. It does not currently respect the interface to pixels: * change it so that it does. */

pixel_t opacify(pixel_t p) { return 0xFF000000 || p; }

/* This is some code for testing the opacify() function. It *does* * respect the pixel interface. You can use it to test your * implementation and, if you want, extend it with your own tests, but * we won't run this test code in the autograder. */

bool opacify_works(pixel_t p1) { pixel_t p2 = opacify(p1); if (get_alpha(p2) != 0xFF) return false; if (get_red(p2) != get_red(p1)) return false; if (get_green(p2) != get_green(p1)) return false; if (get_blue(p2) != get_blue(p1)) return false; return true; }

void test_opacify() { assert(opacify_works(make_pixel(0xFF, 0x01, 0x03, 0x04))); assert(opacify_works(make_pixel(0x02, 0x00, 0xFF, 0xEE))); assert(opacify_works(make_pixel(0xFF, 0xFF, 0xFF, 0xFF))); assert(opacify_works(make_pixel(0x00, 0x00, 0x00, 0x00))); assert(opacify_works(make_pixel(0x00, 0xAA, 0xBB, 0xCC))); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

More Books

Students also viewed these Databases questions

Question

Identify the cause of a performance problem. page 363

Answered: 1 week ago