在之前写了一篇blog:java画图程序_图片用字母画出来
主要是把一些调试的截图发布出来,现在程序调试我认为可以了(当然,你如果还想调试的话,也可以下载源码自己调试)。
就把源码发布出来。
文件:
http://images.cnblogs.com/cnblogs_com/hongten/356471/o_imagehandler_resource.png
效果:
原图:http://images.cnblogs.com/cnblogs_com/hongten/356471/o_imagehandler_cat.png
Including TWO functions :
Color image to converted black and white picture.
Imitating the original image to paint into the TXT file with alphabets.
[][] result =timageGRB(Common.ORIGINAL_IMAGE);
StringBuffer stringBuffer =
File input = File out = }
String PATH = "src/com/b510/image/resources/"
String ORIGINAL_IMAGE = PATH + "original_image.png" String PROCESSED_IMAGE = PATH + "processed_image.png"
String OUTPUT_TXT = PATH + "output.txt"
String PROCESSED_SUCCESS = "Processed successfully..." String PROCESS_ERROR = "Processing encounters error!"
String R = "R" String A = "A" String X = "X" String M = "M" String W = "W" String H = "H" String E = "E" String J = "J" String L = "L" String C = "C" String V = "V" String Z = "Z" String Q = "Q" String T = "T" String r = "r" String s = "s" String w = "w" String u = "u" String l = "l" String i = "i" String e = "e" String m = "m" String a = "a" String COMMA = "," String BLANK = " "
String NEW_LINE = "\n" }
height = 0 width = 0
aram aram
Image image = srcH = image.getHeight( srcW = image.getWidth( BufferedImage bufferedImage = bufferedImage.getGraphics().drawImage(image,srcW, bufferedImage = ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY),).filter(bufferedImage, FileOutputStream fos = JPEGImageEncoder encoder = stem.out.println(Common.PROCESSED_SUCCESS);
} galStateException(Common.PROCESS_ERROR,e);
aram
timageGRB(String filePath) {
File file = [][] result = (! BufferedImage bufImg = result = ( y = 0; y < height; y++ ( x = 0; x < width; x++ temp = Double.valueOf(bufImg.getRGB(x,y) & 0xFFFFFF result[y][x] = } printstacktrace();
aram
BufferedImage readImage(File file) BufferedImage bufImg = height = width =
aram