Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resolution adaption of the captured screen #569

Merged
merged 2 commits into from
Oct 29, 2017

Conversation

gubjack
Copy link
Contributor

@gubjack gubjack commented Oct 25, 2017

It might be useful the adapt the resolution of a captured screen as one would be able with a normal camera.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 19.891% when pulling c0dcef6 on gubjack:capture-resolution into 0e0ccae on sarxos:master.

BufferedImage screen = robot.createScreenCapture(bounds);
int width = resolution.width;
int height = resolution.height;
BufferedImage img = new BufferedImage(width, height, screen.getType());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider checking if screen image from Robot has the same size as resolution Dimension and return original screen image in such a case, so we do not need to create resized image when it's unnecessary.

if (screen.getWidth() == width && screen.getHeight() == height) {
  return screen;
}

@sarxos
Copy link
Owner

sarxos commented Oct 25, 2017

Hi @gubjack, thank you for this PR :) This is really nice functionality. I added one comment in regards to the changes you made.

@gubjack
Copy link
Contributor Author

gubjack commented Oct 25, 2017 via email

@sarxos
Copy link
Owner

sarxos commented Oct 26, 2017

Sure. I can merge this now and add mentioned fix later if you like.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 19.884% when pulling ffbcacf on gubjack:capture-resolution into 0e0ccae on sarxos:master.

@sarxos
Copy link
Owner

sarxos commented Oct 29, 2017

Thank you @gubjack! I'm merging this.

@sarxos sarxos merged commit d2d9a40 into sarxos:master Oct 29, 2017
@gubjack
Copy link
Contributor Author

gubjack commented Oct 30, 2017

👌

@gubjack gubjack deleted the capture-resolution branch December 26, 2017 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants