public int getHeight(int w, int h) // former images size
{
// int hhh;
if (w > wideth) {
float ww;
ww = (float) w / (float) wideth;
float hh = h / ww;
return (int) hh;
} else {
this.setWideth(w);
return h;
}
}
public void proce(String fpath) throws Exception {
File _file = new File(fpath);
Image src = javax.imageio.ImageIO.read(_file);
int wideth = src.getWidth(null);
int height = src.getHeight(null);
int h = this.getHeight(wideth, height);
BufferedImage tag = new BufferedImage(this.getWideth(), h,
BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(src, 0, 0, this.getWideth(), h, null);
if (t != null) {
g.setColor(new Color(242, 242, 242));
g.fillRect(this.getWideth() - 120, h - 18, 120, 1;
g.setColor(new Color(180, 180, 180));
g.drawRect(this.getWideth() - 120, h - 18, 119, 17);
g.setColor(new Color(255, 102, 0));
g.drawString(t, this.getWideth() - 100, h - 5);
}
FileOutputStream out = new FileOutputStream(fpath);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag);
out.close();
}