Advertisement
JolyJDIA

Untitled

Jun 28th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1.  public static void main(String[] args) throws IOException {
  2.         BufferedImage img = ImageIO.read(new File("D:\\IdeaProjects\\Test\\src\\main\\resources\\t.jpg"));
  3.  
  4.         for (int x = 0; x < img.getHeight(); ++x) {
  5.             for (int y = 0; y < img.getWidth(); ++y) {
  6.                 Color color = new Color(img.getRGB(y, x));
  7.                 double v = (((color.getRed() * 0.30) + (color.getBlue() * 0.59) + (color.getGreen() * 0.11)));
  8.                 System.out.print(strChar(v));
  9.             }
  10.             System.out.println();
  11.         }
  12.     }
  13.     public static String strChar(double g) {
  14.         if (g >= 240) {
  15.             return " ";
  16.         } else if (g >= 210) {
  17.             return ".";
  18.         } else if (g >= 190) {
  19.             return "*";
  20.         } else if (g >= 170) {
  21.             return "+";
  22.         } else if (g >= 120) {
  23.             return "^";
  24.         } else if (g >= 110) {
  25.             return "&";
  26.         } else if (g >= 80) {
  27.             return "8";
  28.         } else if (g >= 50) {
  29.             return "#";
  30.         } else {
  31.             return "@";
  32.         }
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement