|
-
Jan 14th, 2004, 10:19 PM
#1
Thread Starter
Addicted Member
Color information:
Ok...
I need to know how to convert from 4 rgba values ( 0 - 255 ) to one single 32 bit integer.
I already have accuired the code for converting from the integer to rgba:
Code:
public static int [] int2rgba( int px )
{
int [] rgba = new int[4];
rgba[3] = ( px >> 24 ) & 0xff;
rgba[0] = ( px >> 16 ) & 0xff;
rgba[1] = ( px >> 8 ) & 0xff;
rgba[2] = px & 0xff;
return rgba;
}
i need to know how to change the rgba array back... anyone know?
To protect time is to protect everything...
-
Jan 15th, 2004, 03:52 AM
#2
Code:
public int rgba2int(int[] rgba) {
int ret = (rgba[3] << 24) |
(rgba[0] << 16) |
(rgba[1] << 8) |
rgba[2];
}
This will FAIL if any of the rgba members are > 255!
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 17th, 2004, 11:35 AM
#3
Thread Starter
Addicted Member
To protect time is to protect everything...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|