User:C.R./Lab 02
Appearance
//chest'è nu backup d' 'o levaAMiez.java
import javax.imageio.*;
import java.awt.image.BufferedImage;
import java.awt.Color;
import javax.imageio.ImageIO;
import java.io.*;
//S'adda luvà a mmiez' 'a marca 'e ll'innommenabbele
public class levaAMiez{
//facimmo nu poco 'e prugrammazione strutturata pe' ffà prove
//ogne riga 'e pixel ce tenesse nu patrone ... .. .. . .. ....... .. ... ... ..
//so' sicuro ca na riga 'e pixel d' 'a marca innummenabbele tenesse nu patrone ca fosse proporzionalmente
//unico
//accussì avimm'a truvà 'a marca innummenabbele e l'avimm'a luvà sana sana pure sbacantanno 'e pixel 'o culore
//o mettenno 'o culore ca se truvasse avvicin'a chista
public static void main(String... args) throws Exception {
PrintWriter out = new PrintWriter("filename.txt");
BufferedImage image = ImageIO.read(new File("digitized.png"));
for (int y = 0; y < image.getHeight(); y++) {
String dotsLine="";
Boolean isBlack=false;
for (int x = 0; x <image.getWidth(); x++) {
int w = image.getWidth();
int h = image.getHeight();
Color c = new Color(image.getRGB(x, y));
if(c.getRed()+c.getGreen()+c.getBlue()+c.getAlpha()>=1000 && isBlack==true){
isBlack=false;
dotsLine=dotsLine+" ";
}else if(c.getRed()+c.getGreen()+c.getBlue()+c.getAlpha()<1000 && isBlack==false){
isBlack=true;
dotsLine=dotsLine+".";
}else{ dotsLine=dotsLine+" ";
}
}
System.out.println(dotsLine);
out.println(dotsLine);
}
out.close();
}
}