BufferedImage getRGB灰度等效

时间:2012-03-01 16:10:56

标签: java image-processing

我使用以下代码:

public static BufferedImage enlarge(BufferedImage image, int n) {

        int w = n * image.getWidth();
        int h = n * image.getHeight();

        BufferedImage enlargedImage =
                new BufferedImage(w, h, image.getType());

        for (int y=0; y < h; ++y)
            for (int x=0; x < w; ++x)
                enlargedImage.setRGB(x, y, image.getRGB(x/n, y/n));

        return enlargedImage;
}

但是,我希望将它用于灰度图像。 BufferedImage的强度是否与setRGB和getRGB等效?

0 个答案:

没有答案