import javax.servlet.*; import javax.servlet.http.*; import com.sun.image.codec.jpeg.*; //kuulub SUNi JDK-sse import java.awt.image.*; import java.awt.*; import java.io.*; public class piltservlet extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ String tekst=kysimus.getParameter("tekst"); if(tekst==null){tekst="Tervitus!";} int laius=40*tekst.length()+20; int korgus=100; BufferedImage pilt =new BufferedImage(laius, korgus, BufferedImage.TYPE_INT_RGB); BufferedImage pilt2 =new BufferedImage(laius, korgus, BufferedImage.TYPE_INT_RGB); Graphics2D piltg=pilt.createGraphics(); piltg.setColor(Color.white); piltg.fillRect(0, 0, laius, korgus); piltg.setPaint(new GradientPaint(0, 0, Color.yellow, 100, 0, Color.green, true )); piltg.setFont(new Font("Times", Font.ITALIC, 70)); piltg.drawString(tekst, 10, 75); float andmed[]=new float[100]; for(int i=0; i<100;i++)andmed[i]=0.01f; ConvolveOp co=new ConvolveOp(new Kernel(10, 10, andmed)); co.filter(pilt, pilt2); BufferedImage pilt3=pilt2.getSubimage(5, 5, laius-10, korgus-10); //mustad servad ära vastus.setContentType("image/jpeg"); JPEGCodec.createJPEGEncoder(vastus.getOutputStream()).encode(pilt3); } }