The javadoc said:
For efficiency, programmers should call dispose when finished using a Graphics object only if it was created directly from a component or another Graphics object.
So in the following code, should I call graphics.dispose()
before returning?
Or, can I?
{ ...
BufferedImage result = new BufferedImage(toWidth, toHeight, BufferedImage.TYPE_INT_RGB);
java.awt.Graphics graphics=result.getGraphics();
graphics.drawImage(im.getScaledInstance(toWidth, toHeight, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
return result;
}
The BufferedImage result
is returned and used elsewhere.
result
and it's associated graphics object (graphics
) go out of scope after the method call, I'd say yes. – EntomophilousgetGraphics()
again on the returned result? – Margiemarginresult
is returned and used elsewhere. – Cooler