private void getPixels() throws IOException {
        try {
            image = robot.createScreenCapture(screenRect);
            
            /* Just testing. Not needed
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
            ImageIO.write(image, "GIF", ios);
            
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            BufferedImage lowQuality = ImageIO.read(bais);
            RoboServer.log(lowQuality.getColorModel()+"");
            
            try { Thread.sleep(15); }
            catch(InterruptedException e) { e.printStackTrace(); }
            
            image = lowQuality;
            */
       	 
        } catch (OutOfMemoryError oome) {
        	// The memory here should be freed (the image inside the try caused OutOfMemory.
        	RoboServer.log("Out of memory while capturing screen");
            Runtime runtime = Runtime.getRuntime();
            RoboServer.log("Total memory = " + runtime.totalMemory() + " free memory = " + runtime.freeMemory());
        }
        if(image != null) {
            if(newScreen == -1) {
                width = image.getWidth();
                height = image.getHeight();
                pixels = new  int[2][];
                pixels[0] = new int[width * height];
                pixels[1] = new int[width * height];
                
                ColorModel colorModel = image.getColorModel();
                if(colorModel instanceof DirectColorModel) {
                    sendColorModel((DirectColorModel) colorModel);
                }
            }
            
            if(oldScreen == -1) {
                if(newScreen == -1) {
                    newScreen = 0;
                } else {
                    newScreen = 1;
                    oldScreen = 0;
                }
            } else {
                if(newScreen == 0) {
                    newScreen = 1;
                    oldScreen = 0;
                } else {
                    newScreen = 0;
                    oldScreen = 1;
                }
            }
            try {
                PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels[newScreen], 0, width);
                pg.grabPixels();
                if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
                    throw new IOException("failed to load image contents");
                }
            }
            catch (InterruptedException e) {
                throw new IOException("image load interrupted");
            }
        }
    }