社区
Web 开发
帖子详情
eWebEditor在线文本编辑器飞鱼修改版 加水印功能
bamboo8888
2007-09-10 05:51:44
我用的是eWebEditor在线文本编辑器飞鱼修改版(jsp) ,我想添加一下水印功能,请大家指点一下怎么加!
谢谢!
...全文
349
1
打赏
收藏
eWebEditor在线文本编辑器飞鱼修改版 加水印功能
我用的是eWebEditor在线文本编辑器飞鱼修改版(jsp) ,我想添加一下水印功能,请大家指点一下怎么加! 谢谢!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
laogou
2007-09-12
打赏
举报
回复
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);
tag.getGraphics().drawImage(src,0,0,w,h,null);
FileOutputStream out=new FileOutputStream(filePath + newFile); //输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag); //JPEG编码
gim.dispose();
out.close();
}catch(Exception e){
message = e.toString();
}
}
public String getMessage(){
return this.message;
}
public void setFilePath(String filePath){
if(filePath!=null){
this.filePath = filePath;
}else{
this.filePath = "";
}
}
public void setStr(String str){
if(str!=null){
this.str = str;
}else{
this.str = "www.baidu.cn";
}
}
public void setWaterImg1(String str){
if(str!=null){
this.waterImg1 = str;
}else{
this.waterImg1 = "";
}
}
public void setWaterImg2(String str){
if(str!=null){
this.waterImg2 = str;
}else{
this.waterImg2 = "";
}
}
public void setWaterPath(String str){
if(str!=null){
this.waterPath = str;
}else{
this.waterPath = "";
}
}
}
使用时加入bean
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="imageWrite18" scope="page" class="com.image.ImageOperate18"/>
eWebEditor
在线
文本编辑器
飞鱼
修改版
.rar
eWebEditor
在线
文本编辑器
飞鱼
修改版
,用与网站后台开发中对后台管理进行
在线
文本编辑。包含使用说明,实例使用方便
eWebEditor
在线
文本编辑器
飞鱼
修改版
eWebEditor
在线
文本编辑器
飞鱼
修改版
源码
eWebEditor
在线
文本编辑器
吕海鹏修改v0.14
程序名称:
eWebEditor
在线
文本编辑器
吕海鹏
修改版
v0.1.4 软件类别: JSP源码 /
在线
文本编辑器
软件语言: 简体中文 授权方式: 免费版 系统平台: JSP+XML+BEAN 程序下载: http://www.ITstudy.cn 程序演示: ...
eWebEditor
在线
文本编辑器
eWebEditor
在线
文本编辑器
,可以放在JSP中运行,方便简捷
eWebEditor
在线
文本编辑器
For JSP
eWebEditor
在线
文本编辑器
For JSP
eWebEditor
在线
文本编辑器
For JSP
Web 开发
81,094
社区成员
341,710
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章