int height=image.getHeight()/5;[java] view plaincopyprint //logo起始位置,此目的是为logo居中显示
int x=(image.getWidth()-width)/2;
int y=(image.getHeight()-height)/2;
g.drawImage(logo, x, y, width, height, null);
g.dispose();
ImageIO.write(image, "png", new File(imgPath));
} catch (Exception e) {
e.printStackTrace();
}
//logo起始位置,此目的是为logo居中显示
int x=(image.getWidth()-width)/2;
int y=(image.getHeight()-height)/2;
g.drawImage(logo, x, y, width, height, null);
g.dispose();
ImageIO.write(image, "png", new File(imgPath));
} catch (Exception e) {
e.printStackTrace();
}
}其中详细代码可以参考MyMatrixToImageWriter.java类