publicclassMaxMinPictuextendsJFrame{//publicstaticvoidresizeImage(FileInputStreamis,intsize)throwsIOException{System.out.println("yyyyyyyyyyyyyyy");//Stringfile1="file/e....
public class MaxMinPictu extends JFrame{
//
public static void resizeImage(FileInputStream is,int size) throws IOException {
System.out.println("yyyyyyyyyyyyyyy");
//String file1 = "file/e.png";
//File file2 = new File(file);
BufferedImage src = ImageIO.read(is);
double width = src.getWidth();
double height = src.getHeight();
System.out.println("---00000-----"+width+"----000000000---"+height);
// size=40;
double percent = size/width;
int newW = (int)(width*percent);
int newH = (int)(height*percent);
System.out.println("---"+newW+"====="+newH);
BufferedImage image = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_BGR);
Graphics graphics = image.createGraphics();
graphics.drawImage(src, 0, 0, newW, newH, null);
//ImageIO.write(image, "png", arg2);
}
}
展开