1

I am using the following code:

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;
}

However, I wish to use it for a greyscale image. Does BufferedImage have equivalent for setRGB and getRGB for the intensity?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Joseph
  • 2,706
  • 6
  • 42
  • 80
  • 1
    as long as the RGB values for a given pixel are the same, you have a gray pixel. if the source is a grayscale image, you're already done. if not, just convert the colored RGB to a grayscaled one. – vulkanino Mar 01 '12 at 16:15
  • http://stackoverflow.com/questions/2499545/getting-greyscale-pixel-value-from-rgb-colourspace-in-java-using-bufferedimage – vulkanino Mar 01 '12 at 16:16

0 Answers0