问题描述
- 关于图片转换成字符显示java
-
public static String _BitmapConvert(String imgpath) { StringBuffer _sb = new StringBuffer(); File imgfile = new File(imgpath); char[] charset = { 'M' '8' '0' 'V' '1' 'i' ':' '*' '|' '.' ' ' }; try { BufferedImage buff = ImageIO.read(imgfile); int bitmapH = buff.getHeight(); int bitmapW = buff.getWidth(); for (int y = 0; y < bitmapH; y++) { for (int x = 0; x < bitmapW; x++) { int rgb = buff.getRGB(x y); Color c = new Color(rgb); int cc = (c.getRed() + c.getGreen() + c.getBlue()) / 3;//这是什么意思 _sb.append(charset[(int) ((cc * 10 - 1) / 255)]);//还有这?? } _sb.append(""rn""); } } catch (Exception e) { } return _sb.toString();}
解决方案
急急急,拜托了,大家
时间: 2024-09-21 23:30:28