Results 1 to 5 of 5
  1. #1
    pieter24 is offline Member
    Join Date
    Jun 2016
    Posts
    12
    Rep Power
    0

    Default Robot getPixelColor and createScreenCapture System calls

    Hi,

    I dont know if this is the correct group to post this on, but everytime i clicked on advanced java the site logged me out so i could not post it there.

    Anyway, i was wondering if anyone knew which system call is called when the Java Robot class methods: getPixelColor and createScreenCapture are used. I am using windows7.

    One of the reasons i ask this is, that getpixelcolor is really slow. And createScreenCapture is really fast while it pulls in information about many more pixels.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,189
    Rep Power
    12

    Default Re: Robot getPixelColor and createScreenCapture System calls

    How have you determined that one method is slower than the other. Can you provide a short (< 50 lines), compilable, program than demonstrates
    what you are seeing?

    Also, if you are trying to use individual getPixelColor to accomplish what createScreenCapture does, it probably will be slower. I would suspect
    that greater efficiencies can be obtained by copying rasters into a buffer than iterating over a row,column segment of a Screen.

    Regards,
    Jim
    Last edited by jim829; 06-23-2016 at 04:42 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    pieter24 is offline Member
    Join Date
    Jun 2016
    Posts
    12
    Rep Power
    0

    Default Re: Robot getPixelColor and createScreenCapture System calls

    i have tried 300 calls to Robot.getPixelColor(). this took 2-3 seconds to complete. One call to createScreenCapture ( which get all the pixels of the entire screen ) much less then second.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,189
    Rep Power
    12

    Default Re: Robot getPixelColor and createScreenCapture System calls

    Ships in the night. Re-read my first edited reply. You can also look at the source code if you desire. It is easier to do so with an IDE. The API source
    is in src.zip and included in the distribution.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    pieter24 is offline Member
    Join Date
    Jun 2016
    Posts
    12
    Rep Power
    0

    Default Re: Robot getPixelColor and createScreenCapture System calls

    Code that uses: createScreenCapture:

    Java Code:
      try {
        		   Robot robot = new Robot();
        		   BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        		   ImageIO.write(screenShot, "JPG", new File("c:\\tmp\\screen.jpg"));
        	   }
        	   catch ( Exception e) {
        		   e.printStackTrace();
        	   }

    Code that to get the color of 300 pixels

    Java Code:
    try {
            		 Robot robot = new Robot();
            		 
            		
            		 for(int i = 0; i<300;i++) {
            			 robot.getPixelColor(i, i+34); // which pixel does not matter
            		 }
            		
    
            	}
            	catch(Exception e) {
            		e.printStackTrace();
            	}

    The latter runs much much slower. So i was wondering which system calls were used in both instances. Maybe there is a single system call for the first piece of code, and the latter causes
    300 system calls to be made?

Similar Threads

  1. Replies: 3
    Last Post: 09-12-2013, 10:03 PM
  2. Time taken by createscreencapture
    By dkas in forum Advanced Java
    Replies: 3
    Last Post: 02-24-2011, 06:40 PM
  3. time taken by robot.createScreenCapture
    By dkas in forum Advanced Java
    Replies: 1
    Last Post: 02-04-2011, 11:46 PM
  4. Java System Calls
    By jonnytabpni in forum Advanced Java
    Replies: 3
    Last Post: 03-03-2010, 07:04 PM
  5. How to access system calls in java
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-13-2007, 03:12 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
  •