在上一个版本:java画图程序_图片用字母画出来_源码发布 基础上,增加了图片同比例缩放,使得大像素图片可以很好地显示画在Notepad++中。
效果1:
原图:http://images.cnblogs.com/cnblogs_com/hongten/356471/o_imagehandler_result1.png
效果2:
原图:http://images.cnblogs.com/cnblogs_com/hongten/356471/o_imagehandler_result2.png
Including TWO functions :
Color image to converted black and white picture.
Imitating the original image to paint into the TXT file with alphabets.
String SCALED_IMAGE = Common.SCALED + Common.FULL_STOP +
painting(Common.ORIGINAL,SCALED_IMAGE,1
aram
File file = File[] fileList = ( i = 0; i < fileList.length; i++ String originalImagePath = System.out.println("Processing ... " + SCALED_IMAGE = Common.SCALED + Common.FULL_STOP + painting(originalImagePath,1 Thread.sleep(4000);
} printstacktrace();
painting(String originalImagePath,String scalImagepath, [][] result =timageGRB(scalImagepath);
StringBuffer stringBuffer =
File input = File out = }
String PATH = "src/com/b510/image/resources/"
String ORIGINAL = PATH + "original.jpg" String SCALED = PATH + "scaled"
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 FULL_STOP = "." 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