All pastes #823953 Raw Edit

Mine

public text v1 · immutable
·published 2007-12-19 18:15 UTC
rendered paste body
int w = oldImage.getWidth(null);
int h = oldImage.getHeight(null);
// Assume we have a handle to a GraphicsConfig object
// Create a compatible image
BufferedImage bImg =
graphicsConfig.createCompatibleImage(w, h);
// Get the image Graphics
Graphics g = bImg.getGraphics();
// Copy the contents from the old image into the new one
g.drawImage(oldImage, 0, 0, null);
// dispose the temporary Graphics object we used
g.dispose();
// Return the BufferedImage
return bImg;
}