import java
import java
import java
import javax
import dec
public class WaterMark {
/**
* 給圖片添加水印
* @param filePath 需要添加水印的圖片的路徑
* @param markContent 水印的文字
* @param markContentColor 水印文字的顏色
* @param qualNum 圖片質量
* @return
*/
public boolean createMark(String filePath
{
ImageIcon imgIcon=new ImageIcon(filePath);
Image theImg =imgIcon
int width=theImg
int height= theImg
//ImageIcon waterIcon=new ImageIcon(watermark);
// Image waterImg =waterIcon
BufferedImage bimage = new BufferedImage(width
Font font = new Font(
Graphics
g
g
g
g
// g
g
g
try{
FileOutputStream out=new FileOutputStream(filePath);
JPEGImageEncoder encoder =JPEGCodec
JPEGEncodeParam param = encoder
param
encoder
out
}catch(Exception e)
{ return false; }
return true;
}
public static void main(String arg[]){
WaterMark wk=new WaterMark();
if(wk
System
}else{
System
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26529.html