int w = buffer.getWidth();
int h = buffer.getHeight();
final ImageTranscoder trans = new PNGTranscoder();
trans.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
application.getXMLParserClassName());
final BufferedImage img = trans.createImage(w, h);
// paint the buffer to the image
Graphics2D g2d = img.createGraphics();
g2d.drawImage(buffer, null, 0, 0);
new Thread() {