求JSP如何显示俩图片成水印效果 各位大虾帮帮忙,我现在,有俩图片,防止别人下载我的图片,就在图片的一角在加一个自己网站的图标。请问,用JSP如何实现??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是透明重叠吧, 用pixel blend 什么的就行哈哈. 具体不大记得了. 主要是pixel blend的算法,有很多blend类型的. package com.tryitsoft.image;import java.awt.*;import java.awt.image.*;import java.io.*;import javax.swing.*;import com.sun.image.codec.jpeg.*;public class WaterMark {/** * 给图片添加水印* @param filePath 需要添加水印的图片的路径* @param Content 水印的文字* @param ContentColor 水印文字的颜色* @param qualNum 图片质量* @return*/public boolean createMark(String filePath,String Content,Color ContentColor,float qualNum) { ImageIcon imgIcon=new ImageIcon(filePath); Image theImg =imgIcon.getImage(); int width=theImg.getWidth(null); int height= theImg.getHeight(null); BufferedImage bimage = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB); Graphics2D g=bimage.createGraphics();g.setColor(ContentColor); g.setBackground(Color.white); g.drawImage(theImg, 0, 0, null ); g.drawString(Content,width/5,height/5); //添加文字 g.dispose(); try{ FileOutputStream out=new FileOutputStream(filePath); JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage); param.setQuality(qualNum, true); encoder.encode(bimage, param); out.close(); }catch(Exception e){ return false; } return true; } } 麻烦各位看下我要跳转到jsp页面为什么跳不过去呢? Hibernate 多对多查询问题 我输入两个时间,如何求出他们的差 tomcat安装好后局域网内怎么访问不起来 网页修改的问题,急急~ 请教怎么样用jbuilder生成.exe文件? 怎样将一个字符串变成一个数字啊? 高分请教关于session的问题 中文传递问题 MyEclipse浏览器和控制台都不报错?? 怎么在tomcat 里面配置虚拟目录 如何在用iText生成PDF表格中,把单元格的边框变成虚线?或者怎么用java画虚线?
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import com.sun.image.codec.jpeg.*;public class WaterMark {
/**
* 给图片添加水印
* @param filePath 需要添加水印的图片的路径
* @param Content 水印的文字
* @param ContentColor 水印文字的颜色
* @param qualNum 图片质量
* @return
*/
public boolean createMark(String filePath,String Content,Color ContentColor,float qualNum)
{
ImageIcon imgIcon=new ImageIcon(filePath);
Image theImg =imgIcon.getImage();
int width=theImg.getWidth(null);
int height= theImg.getHeight(null);
BufferedImage bimage = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
Graphics2D g=bimage.createGraphics();
g.setColor(ContentColor);
g.setBackground(Color.white);
g.drawImage(theImg, 0, 0, null );
g.drawString(Content,width/5,height/5); //添加文字
g.dispose();
try{
FileOutputStream out=new FileOutputStream(filePath);
JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage);
param.setQuality(qualNum, true);
encoder.encode(bimage, param);
out.close();
}catch(Exception e)
{ return false; }
return true;
}
}