I want to write a version of the SAND GAME.
I want to examine the color of every pixel in a Jframe window.
I use something like this.
Toolkit toolkit = Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
int height = dim.height;
int width = dim.width;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
for (int y = height - 1; y >= 0; y--) {
for (int x = width - 1; x >= 0; x--) {
int rgb = bimage.getRGB(x, y);
int red = (rgb & 0x00ff0000) >> 16;
int green = (rgb & 0x0000ff00) >> 8;
int blue = rgb & 0x000000ff;
//CONTINUE WITH SOME CODE
}}
Is it possible to create an image just of the JFrame window i use and not the hole screen?
I don't want to use the bimage.getSubimage(WIDTH, WIDTH, width, width) method or to constantly calculate the Jframe's window coordinates.
Any ideas ? Thanks for your time.