if (img == null) System.out .println("How can img be null here!? battle sprite editor");
if (!BATTLE_SPRITE_SIZES[sp.getSize()].equals(new Dimension(w, h))) { JOptionPane.showMessageDialog(mainWindow, "Invalid image size (" + w + ", " + h + ").\n" + "Make sure the image size matches the\n" + "sprite size you have selected.", "Bad Image Size", JOptionPane.ERROR_MESSAGE); return; }
    public void importBmpImg(File f)    {        try        {            if (f == null)                return;            if (!f.exists())                throw new FileNotFoundException();            BattleSprite sp = getSelectedSprite();            FileInputStream in = new FileInputStream(f);            Image img = mainWindow.createImage(BMPReader.getBMPImage(in));            in.close();            int w = img.getWidth(mainWindow), h = img.getHeight(mainWindow);            if (img == null)                System.out                    .println("How can img be null here!? battle sprite editor");            byte[][] sprite = new byte[w][h];            int[] pixels = new int[w * h];            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;            }            if (sprite == null)                System.out                    .println("How can sprite be null here!? battle sprite editor bmp import");            if (BITMAP_REV_PAL == null)                System.out                    .println("How can BITMAP_REV_PAL be null here!? battle sprite editor bmp import");            for (int j = 0; j < h; j++)            {                for (int i = 0; i < w; i++)                {                    sprite[i][j] = ((Byte) BITMAP_REV_PAL.get(new Integer(                        pixels[j * w + i]))).byteValue();                }            }            sp.setSprite(sprite);            da.setImage(sp.getSprite());            da.repaint();        }        catch (IOException e)        {            System.out.println("Unable to read image: " + f.toString());            e.printStackTrace();        }    }