private void drawToVolatileImage(GraphicsConfiguration config)
    {
        do
        {
            if (vi.validate(config) == VolatileImage.IMAGE_INCOMPATIBLE)
            {
                vi = config.createCompatibleVolatileImage(bi.getWidth(), bi.getHeight(), quality);
            }
            
            if (transparency != 0)
            {
                Graphics2D viGraphics = vi.createGraphics();
                viGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC,
                        transparency));
                viGraphics.drawImage(bi, 0, 0, null);
                viGraphics.dispose();
            }
        } while (vi.contentsLost());
    }