Providing Images with Process.org in a Java Servlet

How to render Processing.org images on a Java servlet?

My scala code:

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);

  }
}
+3
source share
3 answers

I just posted an example code here that sounds like it solves your problem too, take a look. This is Java, not Scala, but the conversion should be trivial.

+1
source

Applets are usually executed on the client side (i.e. inside the browser). If you just call new Image, then plumbing will work around it, for example, a call setup()will not be completed.

, API API. API, PGraphics .

0

, , , "" . ServletUtils Fluid Forms Libs.

, PGraphics. PApplet, , API , , rect(), PGraphics.

0

Source: https://habr.com/ru/post/1717727/


All Articles