JPG

xiaoxiao2021-03-06  57

<% @ page import = "java.awt. *"%> <% @ page import = "java.awt.image. *"%> <% @ page import = "com.sun.image.codec.jpeg. * "%> <% @ Page Import =" java.util. * "%>

<% // test by liboy

INT width = 400; int Height = 400;

BufferedImage Image = New BufferedImage (Width, Height, BufferedImage.Type_INT_RGB); Graphics g = image.getgraphics (); // graphics2d g2d = image.creategraphics ();

G.SetColor (color.white); g.FillRect (0, 0, width, height); g.setcolor (color.black); g.drawRect (0, 0, width-1, height-1); // Create random polygon polygon poly = new polygon (); random random = new random (); for (int i = 0; i <5; i ) {polyxtint (width), random.nextint (Height) );} // Fill Polygon g.setColor (color.red); g.fillpolygon (poly); // dispose context g.dispose ();

Response.reset (); response.setContentType ("Image / JPEG");

ServletOutputStream Sos = response.getOutputStream (); JPEGIMAGEENCODER Encoder = JPEGCODEC.CREATEJPEGENCODER (SOS); Encoder.Encode (Image);

%>

转载请注明原文地址:https://www.9cbs.com/read-113220.html

New Post(0)