This is what I am trying to do... I have a image and I create a bufferedImage and graphics out of that using:

BufferedImage    img = ImageIO.read(file);
           Graphics2D g = img.createGraphics();

Now I play with the graphics and finally save the file using:

File outputfile = new File(outfilename);
        ImageIO.write(img, "png", outputfile);

Now the problem is I want to go in two different directions with the present graphics that I have...for that I need to copy graphics so that I can make different changes on them..like this
myImageFile -> Image1 ->(image2, image3)

.here I am confused if I copy the BufferedImage or the graphics?

To copy the graphics I did,

Graphics2D gIssue = (Graphics2D) g.create();

But this does not work as when I make "the image3", it shows stuffs that I included in "image2" when what I want is it should not have graphicsChanges that occured when image1 was converted to image2.

I hope I did not confuse folks here...
Thanks in Advance! Any help/advice/suggestions is greatly appreciated!

I know I can create Image2 and then create a new BufferedImage and Graphics using the file that I saved the Image1 as ...

But I want to understand if there is any means of copying stuff!

You could try the clone() method that all Java objects have.
BufferedImage img2 = img.clone();
This isn't always implemented for all classes, but if that's the case you'll get a CloneNotSupportedException thrown immediately, so at least you'll know!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.