Java BufferedImage Operation resampleImage(BufferedImage image, int height)

Here you can find the source of resampleImage(BufferedImage image, int height)

Description

resample Image

License

Open Source License

Declaration

public static BufferedImage resampleImage(BufferedImage image, int height) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Graphics;

import java.awt.Image;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage resampleImage(BufferedImage image, int height) {
        double mult = height / ((double) image.getHeight());
        Image unbufScaledImage = image.getScaledInstance((int) (mult * image.getWidth()), height,
                Image.SCALE_DEFAULT);
        BufferedImage scaledImage = new BufferedImage(unbufScaledImage.getWidth(null),
                unbufScaledImage.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
        Graphics g = scaledImage.createGraphics();
        g.drawImage(unbufScaledImage, 0, 0, null);
        g.dispose();//from w ww  .  java2 s .com
        return scaledImage;
    }
}

Related

  1. recolor(BufferedImage img, int newColor)
  2. recolor(BufferedImage src, Color sc)
  3. recombine(BufferedImage[][] blocks)
  4. reorientImage(BufferedImage image, boolean yAxisFlipNeeded, int cwRotationNeeded)
  5. repairImage(final BufferedImage bfi, final List order)
  6. resampleWithAffineTransformOp(BufferedImage srcImage, double sx, double sy)
  7. revertBlackAndWhite(BufferedImage img)
  8. roate90(BufferedImage src)
  9. sample9Points(BufferedImage src, int x, int y)