E
Eric Dalquist
I have a JPanel and I'm exporting it's painted contents to a
BufferedImage and then writing that to the file system. I would like a
way to be able to export only a portion of the JPanel to the image.
Currenlty I get a Rectangle that contains the entire area that I want
to export. Then I do:
BufferedImage outputImg = new BufferedImage(circuitArea.width,
circuitArea.height, BufferedImage.TYPE_INT_RGB);
Graphics g = outputImg.getGraphics();
g.setClip(circuitArea);
this.circuit.paint(g);
Thinking that by setting the clip area I can save just the clipped
area. Well when I create the image with the width & height of the
clipped area it's origin is at 0,0 and the clipped area gets painted
at the x & y of the rectangle so only some or none of the panel
actually gets painted to the image.
Is there a way I can paint just a selected rectangle from a JPanel to
an image without having to create an image large enough to paint the
entire area and then cropping?
BufferedImage and then writing that to the file system. I would like a
way to be able to export only a portion of the JPanel to the image.
Currenlty I get a Rectangle that contains the entire area that I want
to export. Then I do:
BufferedImage outputImg = new BufferedImage(circuitArea.width,
circuitArea.height, BufferedImage.TYPE_INT_RGB);
Graphics g = outputImg.getGraphics();
g.setClip(circuitArea);
this.circuit.paint(g);
Thinking that by setting the clip area I can save just the clipped
area. Well when I create the image with the width & height of the
clipped area it's origin is at 0,0 and the clipped area gets painted
at the x & y of the rectangle so only some or none of the panel
actually gets painted to the image.
Is there a way I can paint just a selected rectangle from a JPanel to
an image without having to create an image large enough to paint the
entire area and then cropping?