public BufferedImage shiftImage(BufferedImage original, int x, int y) {
BufferedImage result = new BufferedImage(original.getWidth() + x,
original.getHeight() + y, original.getType());
Graphics2D g2d = result.createGraphics();
g2d.drawImage(original, x, y, null);
return result;
}
应该管用。
保存
public void SaveImage(BufferedImage image, String filename) {
File outputfile = new File(filename + ".png");
try {
ImageIO.write(image, "png", outputfile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}