Results 1 to 3 of 3
  1. #1
    Bill87 is offline Member
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    Default BufferedImage rgb

    Hello,

    How can I get the individual color values from a BufferedImage, rather then just getting the RGB value?

    I was able to do this with Robot class, but using getPixelColor() is much slower.

    Java Code:
    Color ref = robot.getPixelColor(0, 0);
    
    int r = ref.getRed();
    int g = ref.getGreen();
    int b = ref.getBlue();
    int a = ref.getAlpha();
    Last edited by Bill87; 02-25-2010 at 07:25 PM.

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    I believe the code is:

    Java Code:
    int color = bi.getRGB(...);
    int alpha = color >> 24 & 0xff;
    int red = color >> 16 & 0xff;
    int green = color >> 8 & 0xff;
    int blue = color & 0xff;

  3. #3
    Bill87 is offline Member
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Using BufferedImage
    By timkd127 in forum New To Java
    Replies: 5
    Last Post: 12-19-2009, 10:17 PM
  2. BufferedImage imageScaling
    By MINGxDOG in forum New To Java
    Replies: 2
    Last Post: 11-17-2009, 04:04 PM
  3. BufferedImage through FTP
    By dudejonne in forum New To Java
    Replies: 7
    Last Post: 11-05-2009, 06:36 PM
  4. Converting BufferedImage Into ImageIcon
    By hitmen in forum AWT / Swing
    Replies: 9
    Last Post: 03-25-2009, 09:10 AM
  5. BufferedImage to Byte
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-22-2008, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •