I am trying to take a screenshot in minecraft (binded to F2), convert it to base64, then send it to my website, but none of my screenshots are returning an image, but the dimensions are there, here is an example http://minebook.co.uk/screenshot/48462846
Rectangle screenRectangle = new Rectangle(width, height);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStream b64 = new Base64.OutputStream(os);
if( ImageIO.write(image, "png", b64) ) {
String base64String = os.toString("UTF-8");
// Send screenshot Base 64 to website
String postData = "account=" + ModLoader.getMinecraftInstance().thePlayer.username + "&screenshot=" + base64String;
URL url = new URL("http://minebook.co.uk/ingame/screenshot");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
//write parameters
writer.write(postData);
writer.flush();
// Get the response
StringBuffer answer = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
answer.append(line);
}
writer.close();
reader.close();
ModLoader.getMinecraftInstance().thePlayer.sendChatToPlayer(answer.toString());
}
Any assistance will be greatly appreciated, and if you require more information let me know
Vinny