@Override protected void processInput(float delta) { super.processInput(delta); if (keyboard.keyDownOnce(KeyEvent.VK_1)) { createFile("jpg", "image-creator.jpg"); } if (keyboard.keyDownOnce(KeyEvent.VK_2)) { createFile("bmp", "image-creator.bmp"); } if (keyboard.keyDownOnce(KeyEvent.VK_3)) { createFile("gif", "image-creator.gif"); } if (keyboard.keyDownOnce(KeyEvent.VK_4)) { createFile("png", "image-creator.png"); } if (keyboard.keyDownOnce(KeyEvent.VK_5)) { loadFile("image-creator.jpg"); } if (keyboard.keyDownOnce(KeyEvent.VK_6)) { loadFile("image-creator.bmp"); } if (keyboard.keyDownOnce(KeyEvent.VK_7)) { loadFile("image-creator.gif"); } if (keyboard.keyDownOnce(KeyEvent.VK_8)) { loadFile("image-creator.png"); } }
@Override protected void render(Graphics g) { super.render(g); // draw help g.drawString("", 20, 35); g.drawString("(1) Save JPG", 20, 50); g.drawString("(2) Save GIF", 20, 65); g.drawString("(3) Save BMP", 20, 80); g.drawString("(4) Save PNG", 20, 95); g.drawString("", 20, 110); g.drawString("(5) Load JPG", 20, 125); g.drawString("(6) Load GIF", 20, 140); g.drawString("(7) Load BMP", 20, 155); g.drawString("(8) Load PNG", 20, 170); if (sprite != null) { int x = (canvas.getWidth() - sprite.getWidth()) / 2; int y = (canvas.getHeight() - sprite.getHeight()) / 2; g.drawImage(sprite, x, y, null); g.drawString(loadedFile, x, y + sprite.getHeight() + 15); } else { g.drawString("ERROR - File Not Found!", canvas.getWidth() / 3, canvas.getHeight() / 3); } }