我試圖使用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