我正在尝试使用 Play 输出生成的图像。我不确定我的问题是否与 Play 相关。我正在尝试做与此 PHP 代码相同的事情:
header("Content-type: Image/png");
$map = imagecreatefrompng("$_SESSION[ROOT]/it/cabling/maps/${building}_$floor.png");
... // add annotations
imagepng($map);
看起来我需要使用renderBinary
,但我不确定如何从 aBufferedImage
到InputStream
that renderBinary
want 作为它的论点。
Application.map
行动:
public static void map(String building_code, String ts_code) throws IOException {
BufferedImage image = ImageIO.read(new File("public/images/maps/" + building_code + "_" + ts_code.charAt(0)));
... // Overlay some additional information on the image
// do some sort of conversion
renderBinary(inputStream);
}