// 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) { }
What language is this?
Since this function should return a `pixel', could you also give the definition of `pixel'?
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.
ok thanks!
Join our real-time social learning platform and learn together with your friends!