BufferedImage img = (BufferedImage) in;  int[] pixels = new int[img.getWidth() * img.getHeight()]; int w = img.getWidth(), h = img.getHeight(); PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w); try { pg.grabPixels(); } catch (InterruptedException e) { System.err.println("Interrupted waiting for pixels!"); return; } for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { this.setPixelColor((si.isHFliped() ? (w - 1) - i : i), j, pixels[j * w + i]); } }
convertImage(in, sprite, palette);
        public void setImage(BufferedImage in)        {            sprite = new byte[sprite.length][sprite[0].length];            BufferedImage img = (BufferedImage) in;            int[] pixels = new int[img.getWidth() * img.getHeight()];            int w = img.getWidth(), h = img.getHeight();            PixelGrabber pg = new PixelGrabber(img, 0, 0, w, h, pixels, 0, w);            try            {                pg.grabPixels();            }            catch (InterruptedException e)            {                System.err.println("Interrupted waiting for pixels!");                return;            }            for (int j = 0; j < h; j++)            {                for (int i = 0; i < w; i++)                {                    this.setPixelColor((si.isHFliped() ? (w - 1) - i : i), j,                        pixels[j * w + i]);                }            }        }