×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    49

    Question Capturing the screen pixel color value...

    How can i get the color value of screen pixel...

    I have a methods called from pointerPressed (int ,int ) method. which has to manipulate the color value of the particular pixel coordinate it pointing to..
    Can anyone help me please.. ??
    Regards
    Nilanchala

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Capturing the screen pixel color value...

    Quote Originally Posted by nilanchalapanigrahy View Post
    How can i get the color value of screen pixel...

    I have a methods called from pointerPressed (int ,int ) method. which has to manipulate the color value of the particular pixel coordinate it pointing to..
    Can anyone help me please.. ??
    You need to make a mutable image, as you do in case of screen capture and then allow the user to play with pointer over it. -- This you have already done, I assume by now.

    Now to get the color of the selected pixel x,y:

    You can get a unique pixel from an image using the getRGB() method. Here is an example:

    int[] aux=new int[1];
    image1.getRGB(aux,0,image1.getWidth(),x,y,1,1);

    At this moment, you have in aux the ARGB code of the (x,y) pixel contained in the image image1. aux is an array, and then have only one component with the pixel in format 0xAARRGGBB (A=opacity, R=red level, G=green level, B=blue level (levels from 0 to 255)). If you need the red, green and blue levels, you can use it:

    int[] p=new int[3];
    p[0]=(int)((aux[0]&0x00FF0000)>>>16); //Red level
    p[1]=(int)((aux[0]&0x0000FF00)>>>8); //Green level
    p[2]=(int)(aux[0]&0x000000FF); //Blue level

    And if you need the opacity level, you can do it:

    int a=(int)((aux[0]&0xFF000000)>>>24); //Opacity level
    Thanks,
    Ekta

Similar Threads

  1. Comparing pixel color and get___Component()
    By nurru in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-05-07, 12:50
  2. Getting a pixel color value (from a Canvas)
    By dd_plus in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-07-12, 08:04
  3. Replies: 4
    Last Post: 2004-03-22, 08:50
  4. Replies: 5
    Last Post: 2004-03-17, 08:40
  5. color value of a jpg pixel
    By tronicart in forum Symbian
    Replies: 0
    Last Post: 2003-11-25, 12:36

Posting Permissions

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