RenderedImage image = context.get(RasterizingPipelineCode.RENDERED_IMAGE, RenderedImage.class);
ByteArrayOutputStream imageStream = new ByteArrayOutputStream(10 * 1024);
try {
ImageIO.write(image, "PNG", imageStream);
} catch (IOException e) {
throw new RasterException(RasterException.IMAGE_WRITING_FAILED, e);
}
byte[] imageData = imageStream.toByteArray();
response.setImage(imageData);
}