import java.awt.image.BufferedImage;
import java.io.IOException;

public class ImageForString {
	private final static char[] asc = { '*', '.', ' ', ' ' }; 
  public static StringBuilder imageToAscii(BufferedImage image)throws IOException{
	  StringBuilder strb=new StringBuilder();
	  int width=image.getWidth();
	  int height=image.getHeight();
	  for(int i=0;i<height;i++){
		  for(int j=0;j<width;j++){
			  int rgb=image.getRGB(j,i);
			  int R=(rgb&0xff0000)>>16;
		  	  int G=(rgb&0x00ff00)>>8;
		  	  int B=rgb&0x0000ff;
		  	  int gray=R+G+B;
		  	  int index=gray/255;
		  	  strb.append(asc[index]);
		  }
		  strb.append("\n");
	  }
	  
	  return strb;	  
  }
}
最近下载更多
mikumiku399  LV1 2022年1月3日
Jiece123  LV4 2019年10月17日
hwqhwq  LV20 2019年6月19日
totti123456  LV1 2019年3月18日
1037221369  LV1 2018年12月11日
操楷997  LV10 2018年11月21日
Song ling  LV6 2018年11月11日
2283745  LV1 2018年8月16日
wcgyong  LV2 2018年8月16日
奔现翻车现场  LV1 2018年8月10日
最近浏览更多
DongYingdie  LV2 2023年12月21日
1529860026  LV24 2023年4月27日
逍遥2020  LV11 2023年3月29日
y1214435276  LV9 2023年3月22日
微信网友_5992582549164032  LV6 2023年2月21日
Dominick  LV14 2022年11月9日
Kevin_001  LV6 2022年3月26日
mikumiku399  LV1 2022年1月3日
王春与  LV1 2021年12月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友