http://www.robinswebsitestudio.com/ButtonSamples/buttons.html
以下代码会写入预制图像。但是,由此产生的图像存在严重问题。
原始png文件是一个带有Index Transparency和matte的3D按钮,因此gif文件会 融入页面背景颜色
生成的gif文件是平的,遮罩消失了,文本看起来不平滑。所结果的 因此,文件不是您从Adobe Photoshop或Fireworks获得的,而且看起来不像 专业
如果有人有任何建议,我会全力以赴。使用Java获得高质量的3D按钮是不可能的吗?
String pathToWeb = getServletContext().getRealPath(File.separator);
File f = new File(pathToWeb + "activities.png");
BufferedImage bufferedImage = ImageIO.read(f);
// Create a graphics which can be used to draw into the buffered image
Graphics2D g2d = bufferedImage.createGraphics();
g2d.setFont(new Font( "Arial", Font.BOLD, 15 ));
//create a string with black
g2d.setColor(Color.black);
g2d.drawString("Activities", 40, 40);
// Disposes of this graphics context and releases any system resources that it is using.
g2d.dispose();
// Save as gif
File file = new File("myactivities.gif");
ImageIO.write(bufferedImage, "gif", file);