Package fr.formiko.usuel.images
Class image
java.lang.Object
fr.formiko.usuel.images.image
image class that contain a lot of tools to use images.
- Author:
- Hydrolien
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
changeColor(Img imgColor, Pheromone ph)
Change the image color depending of ant Pheromone.static void
delete every FSomething file in REP_TEMPORARY.static void
delete every file in REP_TEMPORARY.static int
countTransparentBorder(BufferedImage in, int lenI, int lenJ, boolean revers, boolean fromTheEnd)
A fonction to count a transparent border of a BufferedImage.static int[]
A fonction to count transparent borders of a BufferedImage.static void
editAllPixels(BufferedImage bi, Function<Integer,Integer> fct)
Edit all pixels of a BufferedImage.static BufferedImage
flipImage(BufferedImage before, boolean vertically)
A tool to flip a BufferedImage.static byte[][]
fullOf(int x, int y, byte b)
Full the color of an array.static BufferedImage
static BufferedImage
get an Image in 1 of the 3 usuals images directories.static BufferedImage
get an Image in a directory.static BufferedImage[]
static BufferedImage[]
static BufferedImage[]
get an array [] of Image.static BufferedImage[]
static BufferedImage[]
static HashMap<String,BufferedImage>
getImagesAsMap(File folder)
Return a new HashMap<String, BufferedImage>.static HashMap<String,BufferedImage>
getImagesAsMap(String folderName)
Return a new HashMap<String, BufferedImage>.static BufferedImage[][]
getImagess(String nom)
static BufferedImage[][]
getImagess(String nom, byte x)
static BufferedImage[][]
getImagess(String nom, int nbr)
static BufferedImage[][]
getImagess(String nom, int nbr, byte x)
get an array [][] of Image.static int
getNbrImages(String n)
static int
getNbrImages(String nom, byte x)
Fined the last existing number of image from x.static int
getNbrImages(String n, String repStable)
static int
getNbrImages(String nom, String repStable, byte x)
Fined the last existing number of image from x on a directorystatic String
getREP()
The Images directory.static String
static String
The Images directory for extra texture.static BufferedImage[]
getScaledInstance(BufferedImage[] img, int width, int height, int hints)
transforme to Scaled instance a Image []static HashMap<String,BufferedImage>
getScaledInstanceFromMap(HashMap<String,BufferedImage> mapIn, int size)
Rezise a HashMap<String, BufferedImage>.static boolean
True is file is an Image.static void
Print a BufferedImage color.static BufferedImage
Try to read an Image filestatic BufferedImage
static void
replaceRectColor(BufferedImage bi, Color col, int x, int y, int width, int height)
Replace a specified rect by given color.static BufferedImage
resize(BufferedImage in, int newHW)
A fonction to getScaledInstance and return a BufferedImage.static BufferedImage
resize(BufferedImage bi, int newW, int newH)
A fonction to getScaledInstance and return a BufferedImage.static BufferedImage
rotateAndCenterImage(BufferedImage bi, int direction)
A fonction to rotate & center a BufferedImage.static BufferedImage
rotateImage(BufferedImage before, double angle)
A fonction to rotate a BufferedImage.static BufferedImage
rotateImage(BufferedImage before, int direction)
A fonction to rotate a BufferedImage.static BufferedImage
rotateImage2(BufferedImage before, int direction, int pivotX, int pivotY)
A fonction to rotate a BufferedImage.static void
static int
taille(int a, int taille)
Return size of a Creature image.static int
taille(int idEspece, int stade, int taille)
Return size of a Creature image.static int
tailleFourmi(int idEspece, int typeF, int taille)
Return size of a Creature image.static BufferedImage
Replace color by black & white shade.static BufferedImage
translateImage(BufferedImage before, int xOffset, int yOffset, int width, int height)
A fonction to translate a BufferedImage.static BufferedImage
A fonction to trim a BufferedImage.
-
Constructor Details
-
image
public image()
-
-
Method Details
-
getREPTEXTUREPACK
The Images directory for extra texture.
You can add new image that will be used as the game texture (as chargement(Max+1)). Or You can replace some images by puting an image with the same name than an actual image in getREP() or REP_TEMPORARY. -
setREPTEXTUREPACK
-
getREP
The Images directory. -
getREPTEMPORARY
-
readImage
Try to read an Image file
Image are File who end with ".png" or ".jpg".- Parameters:
f
- File that sould contain the Image.- Returns:
- Image on the file or null if something went wrong.
-
readImage
-
getImage
get an Image in 1 of the 3 usuals images directories.
It will 1a search on getREPTEXTUREPACK(), then in getREP() and finaly in REP_TEMPORARY. Image are File who end with ".png" or ".jpg".
.png or .jpg do not need to be precised on the name.- Parameters:
nom
- Name of the file without getREP() part.returnImageNull
- If true it will return an error image insted of null.
-
getImage
-
getImage
get an Image in a directory.
Image are File who end with ".png" or ".jpg".
.png or .jpg do not need to be precised on the name.- Parameters:
nom
- Name of the file without getREP() part.repTemp
- directory were to search.
-
getImages
get an array [] of Image.
Image are File who end with ".png" or ".jpg"- Parameters:
nom
- Name of the file without getREP() part and number and .png or .jpg part of it.nbr
- Number of image that we want.lettre
- A letter that can be after the number on rotated image file. ' ' or 'ø' if there is no letter after the number.k
- Needed only if k!=0. k is the 1a number of the numbering.
-
getImages
-
getImages
-
getNbrImages
Fined the last existing number of image from x.
Image are File who end with ".png" or ".jpg"- Parameters:
nom
- Name of the file without getREP() part and number and .png or .jpg part of it.x
- Needed only if x!=0. x is the 1a number of the numbering.
-
getNbrImages
-
getNbrImages
Fined the last existing number of image from x on a directory
Image are File who end with ".png" or ".jpg"- Parameters:
nom
- Name of the file without repStable part and number and .png or .jpg part of it.repStable
- Directory name.x
- Needed only if x!=0. x is the 1a number of the numbering.
-
getNbrImages
-
getImages
-
getImages
-
getImagess
get an array [][] of Image.
Image are File who end with ".png" or ".jpg"
This metode will always return a new Image [4][nbr] to have the 4 rotated images.- Parameters:
nom
- Name of the file without getREP() part and number and .png or .jpg part of it.nbr
- Number of image that we want.x
- Needed only if x!=0. x is the 1a number of the numbering.
-
getImagess
-
getImagess
-
getImagess
-
getScaledInstance
public static BufferedImage[] getScaledInstance(BufferedImage[] img, int width, int height, int hints)transforme to Scaled instance a Image []- Parameters:
width
- the width to which to scale the image.height
- the height to which to scale the image.hints
- flags to indicate the type of algorithm to use for image resampling.
-
clearTemporaire
public static void clearTemporaire()delete every file in REP_TEMPORARY. -
clearPartielTemporaire
public static void clearPartielTemporaire()delete every FSomething file in REP_TEMPORARY. -
tailleFourmi
public static int tailleFourmi(int idEspece, int typeF, int taille)Return size of a Creature image.
If ant is not found it will just return taille.- Parameters:
idEspece
- id of the Species (size depend of Species)typeF
- typeF also infulence size of the Anttaille
- taille used if it was 0% realistic return Size with a part of realistic
-
taille
public static int taille(int idEspece, int stade, int taille)Return size of a Creature image.- Parameters:
idEspece
- id of the Species (size depend of Species)stade
- stade also infulence size of the Creaturetaille
- taille used if it was 0% realistic
-
taille
public static int taille(int a, int taille)Return size of a Creature image.- Parameters:
a
- size assumed if it was 100% realistictaille
- size used if it was 0% realistic
-
isImage
True is file is an Image.
An image end with .png or .jpg -
resize
A fonction to getScaledInstance and return a BufferedImage.
If images is alredy resize to the exacte dimention it only return the same image.
cf https://stackoverflow.com/questions/9417356/bufferedimage-resize/9417836#9417836- Parameters:
bi
- The Image to resize.newW
- The new width.newH
- The new height.
-
resize
A fonction to getScaledInstance and return a BufferedImage.
This function use resize(bufferedImage, width, height).
This function resize the biger side to newHW & the other size to keep the proportions.- Parameters:
in
- The Image to resize.newHW
- The new height or width (biger side).
-
rotateAndCenterImage
A fonction to rotate & center a BufferedImage.- Parameters:
bi
- The Image to rotate & centerdirection
- The direction to rotate. Direction are multiplied by 45°
-
trimTransparentBorder
A fonction to trim a BufferedImage.
This function use countTransparentBorders(bufferedImage).- Parameters:
in
- The Image to trim
-
countTransparentBorders
A fonction to count transparent borders of a BufferedImage.
A border is transparent if alpha=0 on all the pixel line.- Parameters:
in
- The Image to count transparent borders
-
countTransparentBorder
public static int countTransparentBorder(BufferedImage in, int lenI, int lenJ, boolean revers, boolean fromTheEnd)A fonction to count a transparent border of a BufferedImage.
A border is transparent if alpha=0 on all the pixel line.- Parameters:
in
- The Image to count transparent borderslenI
- width or height depending of reverslenJ
- width or height depending of reversrevers
- True: revers width & heightfromTheEnd
- True: start from the end of the image (width or height)
-
rotateImage
A fonction to rotate a BufferedImage.- Parameters:
before
- The Image to rotatedirection
- The direction to rotate. Direction are multiplied by 45°
-
rotateImage
A fonction to rotate a BufferedImage.- Parameters:
before
- The Image to rotateangle
- The angle to rotate
-
translateImage
public static BufferedImage translateImage(BufferedImage before, int xOffset, int yOffset, int width, int height)A fonction to translate a BufferedImage.- Parameters:
before
- The Image to translate.xOffset
- offset in x.yOffset
- offset in y.
-
rotateImage2
public static BufferedImage rotateImage2(BufferedImage before, int direction, int pivotX, int pivotY)A fonction to rotate a BufferedImage.- Parameters:
before
- The Image to rotate.direction
- The direction to rotate. Direction are multiplied by 1°.
-
flipImage
A tool to flip a BufferedImage.- Parameters:
before
- The Image to flip.vertically
- True, the image will be flip vertically, false it will be flip horizontally.
-
changeColor
Change the image color depending of ant Pheromone.- Parameters:
imgColor
- the image to change.ph
- the Pheromone to get color from.
-
fullOf
public static byte[][] fullOf(int x, int y, byte b)Full the color of an array. -
getImagesAsMap
Return a new HashMap<String, BufferedImage>.- Parameters:
folder
- folder that contain all images
-
getImagesAsMap
Return a new HashMap<String, BufferedImage>.- Parameters:
folderName
- the name of the folder that contain all images
-
getScaledInstanceFromMap
public static HashMap<String,BufferedImage> getScaledInstanceFromMap(HashMap<String,BufferedImage> mapIn, int size)Rezise a HashMap<String, BufferedImage>.- Parameters:
mapIn
- Map that contains images to rezise
-
printBufferedImageColor
Print a BufferedImage color.- Parameters:
bi
- the bufferedImage to print.
-
replaceRectColor
public static void replaceRectColor(BufferedImage bi, Color col, int x, int y, int width, int height)Replace a specified rect by given color.- Parameters:
bi
- the bufferedImage to usecol
- the color to drawx
- x of the rectangley
- y of the rectanglewidth
- width of the rectangleheight
- height of the rectangle
-
toBlackAndWhite
Replace color by black & white shade.- Parameters:
bi
- the bufferedImage to use
-
editAllPixels
Edit all pixels of a BufferedImage.- Parameters:
bi
- the bufferedImage to editfct
- the function to apply
-