|
create a BufferedImage with the height you want get the graphics from it and draw the image you want to rescale on the graphics of the BufferedImage..
Image originalImage;
int scaledWidth = (int)(image.getWidth() *scaleFactorX);
int scaledHeight = (int)(image.getHeight() * ScaleFactorY);
BufferedImage bi = new BufferedImage(scaledWidth,scaledHeight,1);
Graphics2D g2 = (Graphics2D)bi.getGraphics();
g2.drawImage(originalImage, 0, 0, scaledWidth , scaledHeight , null);
try{
ImageIO.write(bi,"bmp",new File(out));
}catch(Exception e){
}
|