Results 1 to 6 of 6
  1. #1
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default color pixel (robot class) scanning too slow

    I am making a program that scans randomly for pixels on the screen. It uses the robot class to check (robot.getPixelColor(x,y)) each pixel it randomly hops to. The problem is: It is TOO SLOW. I heard you can use BufferedImages, Rasters,etc. Can someone point me to the right direction? Thanks!
    Last edited by crikey; 08-20-2010 at 09:10 PM.

  2. #2
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default

    Nevermind. I solved it. I had to use Raster to get a int[] array.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    I've seen this question posted before, can you post the code that gets the int[] array?

  4. #4
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default

    Java Code:
    	Rectangle screenRect = new Rectangle(0, 0, Toolkit.getDefaultToolkit()
    				.getScreenSize().width, Toolkit.getDefaultToolkit()
    				.getScreenSize().height);
    		BufferedImage grid = robot.createScreenCapture(screenRect);
    		int X = random(0, Toolkit.getDefaultToolkit().getScreenSize().width);
    		int Y = random(0, Toolkit.getDefaultToolkit().getScreenSize().height);
    		int tst[] = null;
    		Raster k;
    		k = grid.getData();
    		tst = k.getPixel(X, Y, tst); //X = the x pixel, Y = the y pixel
    The value 'R' is tst[0], G is tst[1] and B is tst[2]

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    Thanks for the code.

  6. #6
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Thanks for the code.
    Yep. I hope it helps people.

Similar Threads

  1. Java Twain Scanning
    By mwalstra in forum Advanced Java
    Replies: 4
    Last Post: 10-28-2014, 12:57 PM
  2. Scanning Image Pixel by Pixel
    By the_transltr in forum Advanced Java
    Replies: 5
    Last Post: 08-28-2012, 05:01 PM
  3. compare two images pixel by pixel
    By java_bond in forum Advanced Java
    Replies: 6
    Last Post: 03-02-2010, 12:27 PM
  4. Scanning in java
    By Waqas in forum Advanced Java
    Replies: 1
    Last Post: 07-10-2009, 09:38 AM
  5. scanning a file and using more than one delimiter
    By thomase in forum New To Java
    Replies: 20
    Last Post: 04-07-2009, 04:04 AM

Posting Permissions

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