Java examples for 2D Graphics:BufferedImage
print Image Alpha Raster
import java.awt.Image; import java.awt.image.BufferedImage; public class Main{ public static void printImageAlphaRaster(BufferedImage image) { int width = image.getWidth(); int[] imgData = new int[width]; System.out.print(" ||"); for (int x = 0; x < width; x++) { System.out.print(Objected2DUtils.extendString(x, "0", 3) + "|"); }//w w w. ja v a 2s. c o m System.out.print("\n-------"); for (int x = 0; x < width; x++) { System.out.print("----"); } System.out.print("\n"); for (int y = 0; y < image.getHeight(); y++) { // fetch a line of data from each image image.getRGB(0, y, width, 1, imgData, 0, 1); // apply the mask System.out.print(" " + Objected2DUtils.extendString(y, "0", 3) + " ||"); for (int x = 0; x < width; x++) { String string = String.valueOf(((imgData[x] >> 24) & 0xFF)); while (string.length() < 3) { string = "0" + string; } System.out.print("" + string + "|"); } System.out.print("\n"); } } public static String extendString(Object stringO, String extender, int length) { String string = String.valueOf(stringO); while (string.length() < length) { string = extender + string; } return string; } }