I want to dynamically create some image from Java and save it to a file. As I read in various tutorials, I need to use BufferedImage.
But, the BufferedImage constructor requires that the height and width as parameters. But I don't know the final size of my image. How should I create an image with size unknown in advance?
There are two obvious strategies:
- Create a very large image initially, say 10000x10000.
- Gradually creating larger image, and copying the original to it. The drawback is that I need to check the bounds before each time I want to add something.
How do you deal with this problem?