![]() |
| | #1 |
| Registered User Join Date: Jul 2003
Posts: 110
| Short to 16bit 555 format I have a file which I read in shorts. Each short represents a color. I need to make the short into a RGB color using 555 format. F = Alpha Red = E to A Green = 9 to 5 Blue = 4 to 0. So I made the function Code: public Color getColor(short value)
{
short R = (value & 0xF800) >> 10;
short G = (value & 0x07C0) >> 5;
short B = (value & 0x003E);
return Color.FromArgb(R, G, B);
}
Error 1 Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) On each of the conversions. I looked this up in a couple places and it said almost the same thing, can anyone help me? Thankyou. |
| Coder87C is offline | |
| | #2 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,640
| My guess is it wants you to cast your hex values to a short, but I don't C#. Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
| | #3 |
| Registered User Join Date: Jul 2003
Posts: 110
| What I did was changed it to: int R = (value & 0xF800) >> 10; so int R not short R. Can this screw things up? |
| Coder87C is offline | |
| | #4 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,640
| That depends if you really need a short or an int. In C you'd just do something like this, that is, if you really needed to: Code: short int R = (value & (short int)0xABC) >> 10; Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing Structures Inside Structures | Mellowz | C Programming | 1 | 01-13-2008 03:55 AM |
| Help calling function is asm | brietje698 | C++ Programming | 24 | 12-06-2007 04:48 PM |
| Say what? - Weird error. | Blackroot | C++ Programming | 6 | 08-15-2006 11:54 PM |
| Does Anybody Know How I Could Get The Date (In Short Format) | rocky8015 | C Programming | 4 | 06-07-2005 10:57 AM |
| Color Variety | Unregistered | C++ Programming | 7 | 10-23-2002 09:17 AM |