java createScreenCapture litle black on MAC
in
Programming Questions
•
1 year ago
When using createScreenCapture from the Java robot class then the capture get's darker and darker.
First i thought it has to do with the shadows mac has around the windows so i used the program shadowkiller to get rid of them but it doesn't help.
Does anyone know where this is coming from?
- import processing.opengl.*;
- import java.awt.Robot;
- import java.awt.image.BufferedImage;
- import java.awt.Rectangle;
- import java.awt.AWTException;
- import java.awt.Point;
- import java.awt.Insets;
- Insets insets;
- Robot robot;
- PImage img;
- Point winloc;
- void setup() {
- size(screenWidth/3, screenHeight/3, OPENGL);
- try {
- robot = new Robot();
- }
- catch (AWTException e) {
- System.out.println("Couldn't instatiate Robot class.");
- e.printStackTrace();
- }
- insets = frame.getInsets();
- smooth();
- }
- // . . . . . . . . . . . . . . . . . . .
- void draw() {
- background(255);
- winloc = frame.getLocation();
- img = getImage(winloc.x, winloc.y + insets.top, width, height);
- //fastblur(img, 20);
- image(img, 0, 0);
- }
- // . . . . . . . . . . . . . . . . . . .
- private PImage getImage(int x, int y, int w, int h) {
- PImage currentImage = new PImage();
- try {
- BufferedImage image = robot.createScreenCapture(
- new Rectangle(x, y, w, h));
- currentImage = new PImage(image);
- }
- catch (NullPointerException e) {
- e.printStackTrace();
- }
- return currentImage;
- }
1