html可以设置水印的文本编辑器,eWebEditor在线文本编辑器飞鱼修改版 加水印功能解决方法...

当前位置:我的异常网» Java Web开发 » eWebEditor在线文本编辑器飞鱼修改版 加水印功能解

eWebEditor在线文本编辑器飞鱼修改版 加水印功能解决方法

www.myexceptions.net  网友分享于:2013-01-17  浏览:40次

eWebEditor在线文本编辑器飞鱼修改版 加水印功能

我用的是eWebEditor在线文本编辑器飞鱼修改版(jsp)   ,我想添加一下水印功能,请大家指点一下怎么加!

谢谢!

------解决方案--------------------

java水印组件和jspsmart组件的综合使用

要改写webedit的上传文件用百度搜ImageOperate

ImageOperate18.java

package com.image;

import java.awt.*;

import java.awt.image.*;

import javax.imageio.ImageIO.*;

import java.io.*;

import com.sun.image.codec.jpeg.JPEGCodec;

import com.sun.image.codec.jpeg.JPEGImageEncoder;

public class ImageOperate18 {

Image img1;

String message = " ";

String filePath = " "; //程序本身所在的根目录, 绝对路径。

String waterImg1 = " ", waterImg2= " "; //水印图片文件名

String waterPath = " "; //水印图片所在路径,绝对路径

String str = new String( "www.baidu.cn ");

public void waterImage(String oldFile, String newFile){

/* oldFile加水印前的文件名.

* newFile加水印后的文件名。

*/

try{

File myFile = new File(filePath + oldFile); //指定文件名含路径

Image src = javax.imageio.ImageIO.read(myFile); //构造Image对象

int w=src.getWidth(null); //得到源图宽

int h=src.getHeight(null); //得到源图长

Graphics gim = src.getGraphics();

BufferedImage tag = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);

tag.getGraphics().drawImage(src,0,0,w,h,null);

if(!waterImg1.equals( " ") && waterImg2.equals( " ")){

Image img1 = javax.imageio.ImageIO.read(new File(waterPath+waterImg1));//构造Image对象

int w1 = img1.getWidth(null); //得到源图宽

int h1 = img1.getHeight(null); //得到源图长

tag.getGraphics().drawImage(img1,w-w1-12,h-30,w1,h1,null);

}

if(!waterImg1.equals( " ") && !waterImg2.equals( " ")){

Image img1 = javax.imageio.ImageIO.read(new File(waterPath+waterImg1));//构造Image对象

int w1 = img1.getWidth(null); //得到源图宽

int h1 = img1.getHeight(null); //得到源图长

Image img2 = javax.imageio.ImageIO.read(new File(waterPath+waterImg2));//构造Image对象

int w2 = img2.getWidth(null); //得到源图宽

int h2 = img2.getHeight(null); //得到源图长

tag.getGraphics().drawImage(img2,w-w2-12,h-30,w2,h2,null);

tag.getGraphics().drawImage(img1,w-w1-w2-15,h-32,w1,h1,null);

}

FileOutputStream out=new FileOutputStream(filePath + newFile); //输出到文件流

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

encoder.encode(tag); //JPEG编码

gim.dispose();

out.close();

}catch(Exception e){

message = waterPath + e.toString() + filePath;

}

}

public void writeImage(String oldFile, String newFile){

//设置字体

try{

File myFile = new File(filePath + oldFile); //指定文件名含路径

Image src = javax.imageio.ImageIO.read(myFile); //构造Image对象

int w=src.getWidth(null); //得到源图宽

int h=src.getHeight(null); //得到源图长

//在你创立的image上写字

Graphics gim = src.getGraphics();

Font font = new Font( "Tahoma ", Font.BOLD, 18);

gim.setFont(font);

gim.setColor(Color.black);

gim.drawString(str, w-(str.length()*10-3), h-5);

gim.setColor(Color.lightGray);

gim.drawString(str, w-(str.length()*10-2), h-6);

BufferedImage tag = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值