Results 1 to 3 of 3

Thread: Color information:

  1. #1

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228

    Exclamation 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...

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    OK thanx!
    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
  •  



Click Here to Expand Forum to Full Width