public static boolean importFromAwtBufferedImage(
        BufferedImage input, RGBImage output
    )
    {
        int w = input.getWidth();
        int h = input.getHeight();
        int w2 = output.getXSize();
        int h2 = output.getYSize();

        if ( w != w2 || h != h2 ) {
            if ( !output.initNoFill(w, h) ) {
                return false;
            }
        }

        ColorModel cm = input.getColorModel();
        int x, y;
        int pixel;
        RGBPixel p = new RGBPixel();

        if ( cm.getNumColorComponents() == 3 ) {
            for ( y = 0; y < h; y++ ) {
                for ( x = 0; x < w; x++ ) {
                    // Warning: This method call is so slow...
                    pixel = input.getRGB(x, y);
                    p.r = (byte)((pixel & 0x00FF0000) >> 16);
                    p.g = (byte)((pixel & 0x0000FF00) >> 8);
                    p.b = (byte)((pixel & 0x000000FF));
                    output.putPixelRgb(x, y, p);
                }
            }
        }
        else if ( cm.getNumColorComponents() == 1 ) {
            DataBuffer db = input.getData().getDataBuffer();
            int i;
            for ( i = 0, y = 0; y < h; y++ ) {
                for ( x = 0; x < w; x++, i++ ) {
                    p.r = p.g = p.b = VSDK.unsigned8BitInteger2signedByte((db.getElem(i) & 0x000000FF));
                    // Warning: This method call is so slow...
                    output.putPixelRgb(x, y, p);
                }
            }
        }
        else {
            VSDK.reportMessage(null, VSDK.FATAL_ERROR, "importFromAwtBufferedImage", "ColorSpace encoding not supported!");
        }
        return true;
    }