我试图使用Play输出生成的图像。我不确定我的问题是否是特定于游戏的。我试图做到这一点PHP代码做同样的事情:使用Play框架将生成的图像发送到浏览器
header("Content-type: Image/png");
$map = imagecreatefrompng("$_SESSION[ROOT]/it/cabling/maps/${building}_$floor.png");
... // add annotations
imagepng($map);
它看起来像我需要使用renderBinary
,但我不知道如何从BufferedImage
获取到InputStream
是renderBinary
希望其论据。
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);
}
为什么你创建的ImageInputStream是,它不会在以后使用? – 2013-08-26 13:42:02
@AlexanderKjäll从我复制的方法中继承了另一个工件 - 我不确定它做了什么,因此我只是离开了它,假设框架作者有一个原因。你当然可以尝试删除它。 – 2013-08-26 16:12:13