JSP写的图片输出页面。
过程是把图片A绘到另一张模板图片B上,但更换图片A后输出的始终是最初的输出图片,只有重启tomcat后才更新,删除work目录下的文件都不行。
请问这是什么原因造成的?
过程是把图片A绘到另一张模板图片B上,但更换图片A后输出的始终是最初的输出图片,只有重启tomcat后才更新,删除work目录下的文件都不行。
请问这是什么原因造成的?
解决方案 »
- sql server 不允许从数据类型 varbinary 到 date 的隐式转换
- Mysql 字符集
- JSP学习需要注意什么?
- 想购买jsp 空间 请大家介绍以下!
- 笔试有工作经验的人,一般会出些什么题目,web方面
- 为什么我写的applet在本机可以很好的浏览,在别的机器上浏览不行,在IE的状态栏里显示class Myapplet not Found ?各位专家可否指点一下
- 浮点运算的问题
- 杀死一个线程的语句或者方法是什么?
- 有谁用过 Jcreator?帮帮吧!
- (求教)怎么实现一个页面有多个按钮选择,选择一个就传递其对应数据,详细内看
- DAO模式登录验证报空指针异常
- JSP页面无法跳转到指定页面
多刷新几次
使用完之后对其使用img. Dispose();
这个内存管理我也不太会
out.println("<img border=1 src='getImage.jsp&RAND_ID="+System.currentTimeMillis()+"'>");
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;import javax.imageio.ImageIO;
import javax.swing.ImageIcon;public class NewIMG {
BufferedImage template = null;
Graphics2D g = null; public NewIMG(String templatePath) {
try {
this.template = ImageIO.read(new File(templatePath));
} catch (IOException e) {
System.out.println("模板读取失败!" + e.getMessage());
}
g = (Graphics2D) this.template.getGraphics();
} public boolean drawHead(String path) {
ImageIcon head = new ImageIcon(path);
int w = 303, h = 406, iw = head.getIconWidth(), ih = head
.getIconHeight();
double n = 1.0;
if ((w + 0.0) / h < (iw + 0) / ih)
n = (w + 0.0) / iw;
else
n = (h + 0.0) / ih;
return g.drawImage(head.getImage(), 385, 787 - (int) (ih * n + 0.5),
(int) (iw * n + 0.5), (int) (ih * n + 0.5), null);
} public void drawInfo(String name, String post, String date) {
g.setColor(Color.black);
g.setFont(new Font("宋体", Font.BOLD, 54));
g.drawString(name, 350, 931);
g.drawString(post, 350, 1012);
g.drawString(date, 350, 1093); } public BufferedImage Enlarge(BufferedImage src, double multiple) {
AffineTransformOp op = new AffineTransformOp(
AffineTransform.getScaleInstance(multiple, multiple), null);
return op.filter(src, null);
} public void Out(File file, String type, double multiple) {
try {
ImageIO.write(Enlarge(template, multiple), type, file);
} catch (IOException e) {
System.out.println("导出图片失败!" + e.getMessage());
}
} public void Out(OutputStream output, String type, double multiple) {
try {
ImageIO.write(Enlarge(template, multiple), type, output);
} catch (Exception e) {
System.out.println("导出图片失败!" + e.getMessage());
}
} public void flush() {
g.dispose();
g.dispose();
template.flush();
System.gc();
}
}