Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
import java.io.*; import java.awt.*; import java.awt.image.*; import javax.swing.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; // from http://forum.java.sun.com/thread.jspa?threadID=779948&tstart=270 public class ReadImage { public static void main ( String [] args) { if (args.length <= 0) System.exit(0); String fileName = args[0]; try { ColorModel rgb = ColorModel.getRGBdefault(); BufferedImage bi = ImageIO.read(new File(fileName)); for(int y=0;y<bi.getHeight();++y) for(int x=0; x<bi.getWidth();++x) { int color = bi.getRGB(x,y); int green = rgb.getGreen(color); int blue = rgb.getBlue(color); int red = rgb.getRed(color); System.out.println("(" + x + ", " + y + ") = (" + red + ", " + green + ", " + blue + ")"); } } catch (Exception e) { System.out.println(e); e.printStackTrace(); } } }
This paste will be private.
From the Design Piracy series on my blog: