public Object generateImageWithOrientation(Image src,
public static Image generateImageWithOrientation(Image src,
    public Object generateImageWithOrientation(Image src,            int orientation) {        if (orientation == 0) {            return queryImageId(src);        } else {            int w = src.getWidth(null), h = src.getHeight(null);            int[] old_pixels = new int[w * h];            PixelGrabber p = new PixelGrabber(src, 0, 0, w, h,                    old_pixels, 0, w);            try {                p.grabPixels();            } catch (InterruptedException e) {            }            int[] new_pixels = new int[w * h];            int dest_w = ((orientation & 4) != 0) ? h : w;            int dest_h = ((orientation & 4) != 0) ? w : h;            for (int dest_y = 0; dest_y < dest_h; ++dest_y) {                for (int dest_x = 0; dest_x < dest_w; ++dest_x) {                    int src_x = dest_x, src_y = dest_y;                    if ((orientation & 4) != 0) {                        src_y = dest_w - dest_x - 1;                        src_x = dest_y;                    }                    if ((orientation & 1) != 0) {                        src_x = w - src_x - 1;                    }                    if ((orientation & 2) != 0) {                        src_y = h - src_y - 1;                    }                    new_pixels[dest_x + dest_y * dest_w]                        = old_pixels[src_x + src_y * w];                }            }            old_pixels = null;            BufferedImage new_img = new BufferedImage(dest_w, dest_h,                    BufferedImage.TYPE_INT_ARGB);            new_img.setRGB(0, 0, dest_w, dest_h, new_pixels, 0, dest_w);            return Integer.toString(addImage(new_img));        }    }