各位大虾帮帮忙,我现在,有俩图片,防止别人下载我的图片,就在图片的一角在加一个自己网站的图标。请问,用JSP如何实现???

解决方案 »

  1.   

    就是透明重叠吧, 用pixel blend 什么的就行哈哈. 具体不大记得了. 主要是pixel blend的算法,有很多blend类型的.
      

  2.   

    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; 

    }