print BufferedImage Image - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

print BufferedImage Image

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;

public class Main {
    public static void printImage(BufferedImage image) {
        int w = image.getWidth();
        int h = image.getHeight();
        System.out.println("width, height: " + w + ", " + h);

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.println("x,y: " + j + ", " + i);
                int pixel = image.getRGB(j, i);
                printPixelARGB(pixel);/*www . j a  va  2s.  c  om*/
                System.out.println("");
            }
        }
    }

    public static void printPixelARGB(int pixel) {
        int alpha = (pixel >> 24) & 0xff;
        int red = (pixel >> 16) & 0xff;
        int green = (pixel >> 8) & 0xff;
        int blue = (pixel) & 0xff;
        System.out.println("argb: " + alpha + ", " + red + ", " + green
                + ", " + blue);
    }
}

Related Tutorials