Need help with this C# question

Watch this thread
Agent456
Badges: 17
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 5 months ago
#1
"Colours are often represented as an amount of red, green, blue, and the transparency (a.k.a. alpha). Each R, G, B, and A value can be from 0-255, i.e. 1 byte. On the web and in CSS this is normally represented in a RGBA hexadecimal format such as #FF0000FF where each two characters are 1 byte. #FF0000FF is full red, no green or blue, and fully opaque. Write a function which takes 4 byte values as parameters (Red, Green, Blue, Alpha) and returns a single 4 byte integer with the values packed into RGBA. Also write a function which does the reverse, it receives a 4 byte integer and returns an instance of a Colour class which you also need to create. Make sure this class is serialisable and provide a sample application that shows off this functionality."

Help please?
0
reply
navkan
Badges: 7
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 3 months ago
#2
What have you done so far ?
0
reply
Icy Wolf
Badges: 10
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report 3 months ago
#3
I don't know C#, and I know this reply is very late, but I'll try to give my idea anyway.
Define a function taking inputs R, G, B, A.
Convert hex values into string.
Append text to create a single string with them squished into RGBA
Convert back to hex.
To do the opposite, convert into string.
Then split it into pairs of two, and convert those four values back into hex.

In python it'd be a piece of cake, but the only language I know that's similar to C# is C++, and I'm pretty rusty on it.
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How did your AQA Combined Science - Biology Paper 1 go?

Loved the paper - Feeling positive (59)
34.5%
The paper was reasonable (68)
39.77%
Not feeling great about that exam... (28)
16.37%
It was TERRIBLE (16)
9.36%

Watched Threads

View All