图片水印效果!!!
小弟想实现在上传图片时,加上水印,不知道怎么实现,请用过的兄弟指点一、二
------解决方案--------------------以前的贴子,参考一下吧
http://topic.csdn.net/t/20050402/15/3903402.html
------解决方案--------------------aspjpeg组件很容易实现
------解决方案--------------------package net.csdn.xdj.servlet.d050403;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.struts.upload.FormFile;
import java.io.*;
import net.csdn.xdj.model.d050403.Mark;
/**
* <p> 上传处理,Action </p>
* <p> Title: community.csnd.net </p>
* <p> Description: java问题解答 </p>
* <p> Copyright: Copyright (c) 2005 </p>
* <p> Company: 自由人 </p>
* @author 许德建(simonxuluo)
* @version 1.0
*/
public class UploadImage
extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response) {
UploadAFB form = (UploadAFB) actionForm;
String theAction = form.getTheAction();
form.setTheAction( "uploadImage ");
if (theAction == null) {
theAction = " ";
}
else if (theAction.equals( "uploadImage ")) {
FormFile file = form.getTheFile();
File newFile = new File(form.getNewFile());
if (file == null || newFile == null) {
return mapping.getInputForward();
}
try {
ByteArrayOutputStream baos = Mark.manipulateImage( "许德建 ",
file.getFileData());
FileOutputStream fos = new FileOutputStream(newFile);
baos.writeTo(fos);
fos.close();
baos.close();
request.setAttribute( "message ", "上传成功 ");
return mapping.findForward( "response ");
}
catch (FileNotFoundException ex) {
// error handle
}
catch (IOException ex) {
// error handle
}
}
return mapping.getInputForward();
}
}