diff --git a/src/lecturePdf/Recadrage.java b/src/lecturePdf/Recadrage.java index 5647497..dae81d4 100644 --- a/src/lecturePdf/Recadrage.java +++ b/src/lecturePdf/Recadrage.java @@ -1,5 +1,7 @@ package lecturePdf; + + import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; @@ -17,12 +19,11 @@ import javax.imageio.ImageIO; -public class Recadrage { +public class Recadrage { String dir=""; String filename=""; BufferedImage img; - public Recadrage(String directory,String file) { dir=directory; filename=file; @@ -40,7 +41,7 @@ public class Recadrage { public Recadrage(){ } - public boolean estDroite() { //determine si l'image png/jpg du pdf est droite (doit etre en noir et blanc) + public boolean estDroite1() { //determine si l'image png/jpg du pdf est droite (doit etre en noir et blanc) int count=0; boolean stop=false; for (int ty=0; ty<100 && !stop;ty++) { @@ -57,6 +58,77 @@ public class Recadrage { return true; return false; } + + + + public boolean estDroite(){ + int count=0; + boolean stop=false; + for (int ty=0; ty<100 && !stop;ty++) { + for (int tx=0;tximg.getWidth()/5.4 && count img.getHeight()*0.1) + stop=true; + } + if (entreeEnvers()) + this.img=Recadrage2.rotate(img, 180); + return false; + } + + public boolean aLEnvers() { + boolean stop2=false; + int count=0; + for (int ty2=img.getHeight()-100; ty2img.getWidth()/5.4 && count img.getHeight()*0.1) + stop2=true; + } + return false; + } + + public boolean entreeEnvers() { + boolean stop2=false; + int count=0; + int maxwid=img.getWidth(); + for (int ty2=img.getHeight()-100; ty2img.getHeight()*0.1) + stop2=true; + + } + if (countimg.getHeight())py=img.getHeight()-1; + if(py>=img.getHeight())py=img.getHeight()-1; if(px<0)px=0; - if (px>img.getWidth())px=img.getWidth()-1; + if (px>=img.getWidth())px=img.getWidth()-1; + //System.out.println("px ="+px+" /"+img.getWidth()); + //System.out.println("py ="+py+" /"+img.getHeight()); tmp=new Color(img.getRGB(px, py)); if (tmp.getGreen()>20) { //si pixel == blanc return false; @@ -270,7 +346,7 @@ public class Recadrage { double dadj=Math.sqrt(Math.pow(xb-pointx, 2)+Math.pow(yb-pointy, 2)); //adjacent / rapport a xb,yb - System.out.println("dadj "+dadj + " dhypo "+dhypo); + //System.out.println("dadj "+dadj + " dhypo "+dhypo); if (dhypo