求救 在线等!!! 用Java做的图片处理
这是一段图片缩小的代码 !! 如果只处理一张图片的话 还行 ,但是处理多张图片 速度就太慢了 这个应该怎么解决 啊?
请高手指点 或者还有什么别的方法能让图片处理的速度快一些
Image src = javax.imageio.ImageIO.read(new File(filename)); // 构造Image对象
// 确定缩略图大小的宽度和高度
double thumbRatio = (double) thumbWidth / (double) thumbHeight;
int imageWidth = src.getWidth(null);
int imageHeight = src.getHeight(null);
double imageRatio = (double) imageWidth / (double) imageHeight;
if (thumbRatio < imageRatio)
{
thumbHeight = (int) (thumbWidth / imageRatio);
} else
{
thumbWidth = (int) (thumbHeight * imageRatio);
}
BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = thumbImage.createGraphics();
graphics2D.drawImage(src, 0, 0, thumbWidth, thumbHeight, null);