2

画面上のピクセルの領域を取得して BufferedImage オブジェクトに変換するコードがあります。事は - それは非常に遅いので、私はその速度を上げるためのサポートを探しています!

コードは次のとおりです。

public BufferedImage getScreenPortion(Point topleft,Point bottomright){

    int width = bottomright.x - topleft.x;
    int height = bottomright.y - topleft.y;
    BufferedImage bi = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);

    for(int p=0;p<height;p++){

    for(int i= 0;i<width;i++){

        Color pixel = robot.getPixelColor(topleft.x+i, topleft.y+p);
        bi.setRGB(i, p, pixel.getRGB());
        }
    }

    return bi;


}

そして私はそれを渡しています: getScreenPortion(new Point(1081,824),new Point(1111,844));つまり、約30x20の領域を取得しようとしていますが、7秒の領域を取り込んでおり、非常に遅いです!

4

1 に答える 1

3

修正しました-代わりに次を使用します:

Rectangle screenRect = new Rectangle(topleft.x, topleft.y, width, height);
BufferedImage grid = robot.createScreenCapture(screenRect);
于 2011-11-17T22:54:18.873 に答える