Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

// Returns an int representing an RGB pixel consisting // of the given alpha, red, green and blue intensity // values. (All intensity values must be between // 0 and 255, inclusive. pixel make_pixel(int alpha, int red, int green, int blue) { }

OpenStudy (anonymous):

What language is this?

OpenStudy (anonymous):

Since this function should return a `pixel', could you also give the definition of `pixel'?

OpenStudy (anonymous):

Well, the comments say it returns an int, but the code says it returns a pixel. So something is wrong right away. I'm going to answer in C# since that's the language I use most. I will also assume you wish to use RGBA colour coding. int make_pixel(int alpha, int red, int green, int blue) { int t; t = alpha; t += blue << 8; t += green << 16; t += red << 24; return t; } This is off the top of my head though so please double check it.

OpenStudy (anonymous):

ok thanks!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!