Skip to content

Commit

Permalink
Avoid secondary image creation in case screen resolution is already d…
Browse files Browse the repository at this point in the history
…esired resolution
  • Loading branch information
gubjack committed Oct 28, 2017
1 parent c0dcef6 commit ffbcacf
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Robot;
Expand Down Expand Up @@ -72,6 +71,9 @@ public BufferedImage getImage() {
BufferedImage screen = robot.createScreenCapture(bounds);
int width = resolution.width;
int height = resolution.height;
if (screen.getWidth() == width && screen.getHeight() == height) {
return screen; // No need for adaption
}
BufferedImage img = new BufferedImage(width, height, screen.getType());
Graphics2D g = img.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
Expand Down

0 comments on commit ffbcacf

Please sign in to comment.