Weißes Bild in Java erstellen

Yes you can create, here is the example how can you make it with BufferedImage in Java:

Source Code:

Java:
 java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class CreateWhiteImage {
    public static void main(String[] args) {
        int width = 800; // Width of the image
        int height = 600; // Height of the image

        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

        // Set all pixels to white
        int white = 0xFFFFFFFF;
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                image.setRGB(x, y, white);
            }
        }

        // Save the image to a file
        try {
            File outputFile = new File("white_image.png");
            ImageIO.write(image, "png", outputFile);
            System.out.println("Image created successfully!");
        } catch (IOException e) {
            System.out.println("Error occurred while creating the image: " + e.getMessage());
        }
    }
}

Thanks
 

Neue Themen


Zurück
Oben