- public static BufferedImage resize(BufferedImage img, int newW, int newH) {
- int w = img.getWidth();
- int h = img.getHeight();
- BufferedImage dimg = dimg = new BufferedImage(newW, newH, img.getType());
- Graphics2D g = dimg.createGraphics();
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null);
- g.dispose();
- return dimg;
- }
woensdag 6 april 2011
[Java] Resizing a BufferedImage
Here's a small piece of code that might aid you in resizing a BufferedImage. Most methods I saw on the internet just took the BufferedImage and resized it to fit the screen. This method will return a new bufferedImage with the new width and height.
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten