Class Img

java.lang.Object
fr.formiko.usuel.images.Img
All Implemented Interfaces:
Cloneable

public class Img extends Object implements Cloneable
Img is a BufferedImage where you can edit pixel value, then save it on a local file or draw it.
Author:
Hydrolien
  • Field Details

    • rand

      private Random rand
    • bi

      private BufferedImage bi
    • width

      private int width
    • height

      private int height
    • rouge

      private byte[][] rouge
    • vert

      private byte[][] vert
    • bleu

      private byte[][] bleu
    • alpha

      private byte[][] alpha
  • Constructor Details

    • Img

      public Img(BufferedImage i)
      Constructs a new Img with a BufferedImage.
    • Img

      public Img(String nom)
      Constructs a new Img with a fileName.
    • Img

      public Img(int width, int height)
      Constructs a new grey 50% alpha Img whose width and height are specified by the arguments of the same name.
  • Method Details

    • getBi

      public BufferedImage getBi()
    • getImage

      public BufferedImage getImage()
    • toBufferedImage

      public BufferedImage toBufferedImage()
    • getAlpha

      public byte[][] getAlpha()
    • getA

      public byte[][] getA()
    • getA

      public byte getA(int i, int j)
    • setAlpha

      public void setAlpha()
    • setAlpha

      public void setAlpha(int i, int j, byte x)
    • setA

      public void setA(int i, int j, byte x)
    • getRouge

      public byte[][] getRouge()
    • getR

      public byte[][] getR()
    • getR

      public byte getR(int i, int j)
    • setRouge

      public void setRouge()
    • setRouge

      public void setRouge(int i, int j, byte x)
    • setR

      public void setR(int i, int j, byte x)
    • getVert

      public byte[][] getVert()
    • getG

      public byte[][] getG()
    • getG

      public byte getG(int i, int j)
    • setVert

      public void setVert()
    • setVert

      public void setVert(int i, int j, byte x)
    • setG

      public void setG(int i, int j, byte x)
    • getBleu

      public byte[][] getBleu()
    • getB

      public byte[][] getB()
    • getB

      public byte getB(int i, int j)
    • setBleu

      public void setBleu()
    • setBleu

      public void setBleu(int i, int j, byte x)
    • setB

      public void setB(int i, int j, byte x)
    • getGray

      public byte[][] getGray()
    • setRouge

      public void setRouge(byte[][] x)
    • setVert

      public void setVert(byte[][] x)
    • setBleu

      public void setBleu(byte[][] x)
    • setAlpha

      public void setAlpha(byte[][] x)
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • setARVB

      public void setARVB(int i, int j, int x)
    • setARVB

      public void setARVB(int i, int j, byte x)
    • getPixel

      public Pixel getPixel(int i, int j)
    • getNbrDePixel

      public int getNbrDePixel(Pixel a, int x)
    • getNbrDePixel

      public int getNbrDePixel(Pixel a)
    • equals

      public boolean equals(Object o)
      Standard equals function. Null & other class type proof.
      Overrides:
      equals in class Object
      Parameters:
      o - o is the Object to test. It can be null or something else than this class.
    • clone

      public Img clone()
      Make a copie of the Img.
      Overrides:
      clone in class Object
    • iniWH

      public boolean iniWH()
      Initialize width & height.
    • afficherLesTableaux

      public void afficherLesTableaux()
      Print the ARGB level.
    • add

      public void add(int x, int y, Img ie)
      Add an Img on this.
      It can be used to make the map image.
    • sauvegarder

      public void sauvegarder(String rep, String filename)
      save the Img as a .png image with a correct name.
      Parameters:
      rep - the directory were to save the image.
      filename - the name of the Image file. (without .png).
    • sauvegarder

      public void sauvegarder(String nom)
    • sauvegarde

      public void sauvegarde(String s)
    • save

      public void save(String filename) throws IOException
      try to save the Img.
      Throws:
      IOException
    • draw

      public void draw()
      draw the Img.
    • dessiner

      public void dessiner()
    • afficher

      public void afficher()
    • compterNiveauDeRouge

      public int[] compterNiveauDeRouge()
      Make an array with all red value for all pixel of the Img.
    • compterNiveauDeVert

      public int[] compterNiveauDeVert()
      Make an array with all green value for all pixel of the Img.
    • compterNiveauDeBleu

      public int[] compterNiveauDeBleu()
      Make an array with all blue value for all pixel of the Img.
    • compterNiveauDeAlpha

      public int[] compterNiveauDeAlpha()
      Make an array with all alpha value for all pixel of the Img.
    • compterPixel

      public int compterPixel(Pixel a)
      Count how much pixel there is on the image.
    • compterChaquePixel

      public HashMap<Pixel,​Integer> compterChaquePixel()
      Count how much of eatch pixel there is on the image.
    • compterChaquePixelToHtml

      public void compterChaquePixelToHtml()
      Count how much of eatch pixel there is on the image and create a .html page to store the data.
    • changerPixel

      public void changerPixel(Pixel a, Pixel b)
      Replace pixel a by pixel b.
      On Formiko it is used to create random color for ant and modify the image.
    • changerPixelTransparent

      public void changerPixelTransparent(Pixel b)
      Replace max alpha pixel by an other color.
    • actualiserImage

      public void actualiserImage()
      Use to refresh the BufferedImage before draw it or save it.
    • tourner

      public void tourner(byte x)
      rotate the Img.
      Parameters:
      x - How much do we need to rotate : 1=90° 2=180° -1 or 3 = -90°
    • tourner

      public void tourner(int x)
    • tourner

      public void tourner()
    • changerAlpha

      public void changerAlpha(int x)
      Add x in alpha (non-transparency) to the all image.
      You can remove some alpha with an x<0.
    • supprimerLaTransparencePartielle

      public void supprimerLaTransparencePartielle(int x)
      Replace all non 100% or 0% transparent pixel by a 100% or a 0% transparent pixel.
      On some image it can have some 99% transparent pixel, we may need to transforme them to 0% transparent pixel. (100 transparent pixel can be recolored more easyly.)
      Parameters:
      x - alpha limit level between 0 and 255. If pixel alpha value is higer than x pixel will be at 255 alpha. Other wise it will be at 0 alpha.
    • supprimerLaTransparencePartielle

      public void supprimerLaTransparencePartielle()
    • ombrer

      public void ombrer(Pixel a, int x)
      draw a shadow on the border of a colored zone as ant alitrunk.
    • ombrer

      public void ombrer(Pixel a)
    • rogner

      public void rogner(int a, int b, int c, int d)
      trim the Img.
      Parameters:
      a - How much do we need to trim in pixel before width
      b - How much do we need to trim in pixel before height
      c - How much do we need to trim in pixel after width
      d - How much do we need to trim in pixel after height
    • rognerBordTransparent

      public void rognerBordTransparent()
      trim the Img to cut transparent border.
    • compterBordTransparent

      public int[] compterBordTransparent()
      get how much line are composed of transparents pixels.
    • getResultAsHtmlDiv

      public String getResultAsHtmlDiv(String sr)