Imaging_ToWeb.jsp
%@ page autoFlush="false" import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>
%
String ImageStr = request.getParameter("ID_Text");
if(ImageStr==null || ImageStr.equals(""))
{
response.setContentType("text/html; charset=gb2312");
%>
HTML>
HEAD>
title>Http://www.lionsky.net/title>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
/HEAD>
body>
form id="Form1" method="post">
input type="text" id="ID_Text" name=ID_Text>
input type=submit value="GO">
/form>
/body>
/HTML>
%
}
else
{
out.clear();
response.setContentType("image/jpeg");
response.addHeader("pragma","NO-cache");
response.addHeader("Cache-Control","no-cache");
response.addDateHeader("Expries",0);
int width=300, height=100;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
//以下填充背景顏色
g.setColor(Color.lightGray);
g.fillRect(0, 0, width, height);
String random="random";
//以下設(shè)置前景色
g.setColor(Color.BLACK);
g.drawString("Http://www.knowsky.com",10,20);
g.drawString("Author:Lion[lion-a@sohu.com]",10,40);
g.drawLine(10,50,290,50);
g.drawString(ImageStr,10,70);
g.dispose();
ServletOutputStream outStream = response.getOutputStream();
JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(outStream);
encoder.encode(image);
outStream.close();
}
%>
您可能感興趣的文章:- JSP生成jpeg圖片用于投票
- JSP隨機(jī)驗證圖片如何制作
- Jsp中如何讓圖片在div中居中
- Servlet+Jsp實現(xiàn)圖片或文件的上傳功能具體思路及代碼
- jsp中實現(xiàn)上傳圖片即時顯示效果功能
- jsp fckeditor 上傳中文圖片亂碼問題的解決方法
- jsp實現(xiàn)生成中國國旗圖片效果代碼