Java tutorial
import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import javax.imageio.ImageIO; import javax.xml.bind.DatatypeConverter; public class Main { public static void main(String[] args) throws Exception { int size = 200; BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.BLUE); for (int i = 0; i < size; i += 5) { g.drawOval(i, i, size - i, size - i); } g.dispose(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "png", baos); String data = DatatypeConverter.printBase64Binary(baos.toByteArray()); String imageString = "data:image/png;base64," + data; String html = "<html><body><img src='" + imageString + "'></body></html>"; System.out.println(html); } }