Why is BufferedImage opening a new window?

Viewed 24

I'm trying to write some code that needs to access the RGB values of the pixels of an image. I am using the BufferedImage class. However, when I run the code, my computer redirects me from VS Code to a separate Java window (similar to how the computer redirects you to a Java graphics window) that makes it as if the Java application is running but a physically window is not visible.

    public int[][][] getPixelData(String fileName) {
    File file = new File(fileName);
    try {
        BufferedImage image = ImageIO.read(file);
        int height = image.getHeight();
        int width = image.getWidth();
        int[][][] pixels = new int[height][width][4];
        for (int row = 0; row < pixels.length; row++) {
            for (int col = 0; col < pixels[row].length; col++) {
                int pixel = image.getRGB(row, col);
                int alpha = (pixel >> 24) & 0xf4;
                int red = (pixel >> 16) & 0xf4;
                int green = (pixel >> 8) & 0xf4;
                int blue = pixel & 0xf4;
                int[] data = { alpha, red, green, blue };
                pixels[row][col] = data;
            }
        }
        return pixels;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
0 Answers
Related