How to render Processing.org images on Java servlet?
My scala code is:
class Image extends PApplet {
override def setup {
size(200,200)
background(0)
}
override def draw {
stroke(255)
line(10,10,50,50)
}
def renderImage = g.getImage
}
class ImageServlet extends HttpServlet {
override def doGet(request: HttpServletRequest, response: HttpServletResponse) {
response.setContentType("image/gif")
val os: OutputStream = response.getOutputStream
val image = new Image
javax.imageio.ImageIO.write(image.renderImage.asInstanceOf[RenderedImage],"GIF86", os);
}
}