return cx.toObject(img, global);
return Context.toObject(img, global);
    public static Object imageCtor (Context cx, Object[] args,                Function ctorObj, boolean inNewExpr) {        Object img = null;        try {            if (imggen == null) {                try {                    imggen = new ImageGenerator();                } catch (UnsatisfiedLinkError noawt) {                    System.err.println("Error creating Image: " + noawt);                    throw new RuntimeException("Error creating Image: " + noawt);                }            }            if (args.length == 1) {                if (args[0] instanceof NativeJavaArray) {                    Object obj = ((NativeJavaArray) args[0]).unwrap();                    if (obj instanceof byte[]) {                        img = imggen.createImage((byte[]) obj);                    }                } else if (args[0] instanceof byte[]) {                    img = imggen.createImage((byte[]) args[0]);                } else if (args[0] instanceof String) {                    String imgurl = args[0].toString();                    img = imggen.createPaintableImage(imgurl);                }            } else if (args.length == 2) {                if (args[0] instanceof Number &&                                   args[1] instanceof Number) {                    img = imggen.createPaintableImage(((Number) args[0]).intValue(),                                                          ((Number) args[1]).intValue());                } else if (args[0] instanceof NativeJavaObject &&                        args[1] instanceof NativeJavaObject) {                    // create a new image from an existing one and an image filter                    Object wrapper = ((NativeJavaObject) args[0]).unwrap();                    Object filter = ((NativeJavaObject) args[1]).unwrap();                    img = imggen.createPaintableImage((ImageWrapper) wrapper,                                                          (ImageFilter) filter);                } else {                    throw new RuntimeException("Error creating Image from args "+args[0]+","+args[1]);                }            }        } catch (Exception error) {            System.err.println("Error creating Image: " + error);        }        if (img == null) {            throw new RuntimeException("Error creating image: Bad parameters or setup problem.");        }        return cx.toObject(img, global);    }