I want to use Java to produce an image file (BMP, JPEG, GIF, PNG...) from my code, through the console, not the GUI.
For example, I want my code to produce an image to draw a line from point A to point B, and create a box at the end of Point B, and then output the results to the image file, without displaying the image on the screen to do so.
This is not what I actually want to do with the problem. I want to draw more complex images, but if someone can point me to an example of the above, or point me in the direction, I should be able to figure out the rest.
Thanks ahead of time.
Have you looked into using a BufferedImage object here? I'm no pro at this, but that would be a possible avenue of attack that I'd explore early on.
Just for pointing you, look at the following code segment.
byte utf8 = stringToDraw.getBytes("utf-8");
stringToDraw = new String(utf8);
BufferedImage bufferedImage =
new BufferedImage(400, 400, BufferedImage.TYPE_INT_BGR);
Graphics2D imageGraphic = bufferedImage.createGraphics();
imageGraphic.fillRect(0, 0, 400, 400);
imageGraphic.drawString("String to draw", 20, 20);
Thank you both, this is very helpful. I began using the Processing library to extend Java and make it easier to save images, but I will try this. Thanks!
In the above code segment what I've done is, draw a string and colored the background and save it as an image. You have to think that how to replace your image with that string and save it. Try it out. Good luck.