package com;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class Lanczos {
private static final double WORK_LOAD_FACTOR = 0.265;
private static final double LANCZOS_SUPPORT = 3;
private static final double LANCZOS_WINDOW = 3;
private static final double LANCZOS_SCALE = 1;
private static final double LANCZOS_BLUR = 1;
private static final double EPSILON = 1.0e-6;
private static class ContributionInfo {
private double weight;
private int pixel;
}
public static BufferedImage resizeImage(BufferedImage image, double ratio) {
return resizeImage(image, (int)(image.getWidth() * ratio + 0.5), (int)(image.getHeight() * ratio + 0.5));
}
public static BufferedImage resizeImage(BufferedImage image, double xRatio, double yRatio) {
return resizeImage(image, (int)(image.getWidth() * xRatio + 0.5), (int)(image.getHeight() * yRatio + 0.5));
}
public static BufferedImage resizeImage(BufferedImage image, int width, int height) {
double xFactor = width * 1.0 / image.getWidth();
double yFactor = height * 1.0 / image.getHeight();
BufferedImage resizeImage = new BufferedImage(width, height, image.getType());
BufferedImage filterImage = null;
if (xFactor * yFactor > WORK_LOAD_FACTOR) {
filterImage = new BufferedImage(width, image.getHeight(), image.getType());
horizontalFilter(image, filterImage, xFactor);
verticalFilter(filterImage, resizeImage, yFactor);
} else {
filterImage = new BufferedImage(image.getWidth(), height, image.getType());
verticalFilter(image, filterImage, yFactor);
horizontalFilter(filterImage, resizeImage, xFactor);
}
return resizeImage;
}
private static void verticalFilter(BufferedImage image, BufferedImage resizeImage,
double yFactor) {
double scale = Math.max(1.0 / yFactor, 1.0);
double support = scale * LANCZOS_SUPPORT;
if (support > 16) & 0xFF);
green += alpha * ((rgb >>[img]/images/smiles/icon_cool.gif" alt="[/img]
& 0xFF);
blue += alpha * (rgb & 0xFF);
}
int rgb = roundToQuantum(red) > 16) & 0xFF);
green += alpha * ((rgb >>[img]/images/smiles/icon_cool.gif" alt="[/img]
& 0xFF);
blue += alpha * (rgb & 0xFF);
}
int rgb = roundToQuantum(red) = 255)
return 255;
return (int) (value + 0.5);
}
public static void main(String[] args) throws Exception {
BufferedImage image = ImageIO.read(new File("C:/Program Files/SuperMap/精细化农业气候区划产品制作系统/Bin/Product/广西壮族自治区/广西荔枝/广西荔枝/20101028/广西壮族自治区_广西荔枝_广西荔枝_20101028.bmp"));
ImageIO.write(resizeImage(image, 670, 420), "PNG", new File("C:/Program Files/SuperMap/精细化农业气候区划产品制作系统/Bin/Product/广西壮族自治区/广西荔枝/广西荔枝/20101028/广西壮族自治区_广西荔枝_广西荔枝_20101028_testr.bmp"));
}
}