Java BufferedImage Size Get getSizedImage(final URL url, final Dimension size)

Here you can find the source of getSizedImage(final URL url, final Dimension size)

Description

get Sized Image

License

Apache License

Declaration

public static BufferedImage getSizedImage(final URL url, final Dimension size) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

public class Main {
    public static BufferedImage getSizedImage(final URL url, final Dimension size) throws IOException {
        final BufferedImage image = ImageIO.read(url);
        final BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
        final Graphics2D g = bufferedImage.createGraphics();
        g.drawImage(image, 0, 0, size.width, size.height, null);
        g.dispose();//  ww  w . j a v a  2s  .  c om
        return bufferedImage;
    }
}

Related

  1. getDimension(final Image anImage, final ImageObserver obs)
  2. getDimensions(byte[] image)
  3. getSize(BufferedImage image)
  4. getSize(int width, int height, Image image)
  5. getSizeByHeight(int height, Image image)