Package kiyut.citra.util
Class ImageUtilities
- java.lang.Object
-
- kiyut.citra.util.ImageUtilities
-
public class ImageUtilities extends Object
Image utilitis class. It provides provides static methods for manipulating Images- Author:
- Kiyut
-
-
Constructor Summary
Constructors Constructor Description ImageUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImagecreateImageARGB(int width, int height)Returns aBufferedImagewith type ARGB based on the supplied paramstatic BufferedImagecreateImageARGB(Image src, boolean copy)Returns aBufferedImagewith type ARGB based on the supplied source imagestatic StringgetFileSuffix(File file)Return file suffix portion of give file.static BufferedImagegetScaledInstance(BufferedImage img, int width, int height, boolean autoHint, boolean scaleFit)Return a scaled instance of the providedBufferedImage.static BufferedImagegetScaledInstance(BufferedImage img, int width, int height, Object hint)Return a scaled instance of the providedBufferedImage.static BufferedImagegetScaledInstance(BufferedImage img, int width, int height, Object hint, boolean scaleFit)Return a scaled instance of the providedBufferedImage.static BufferedImageiconToBufferedImage(Icon icon)Returns aBufferedImagerepresentation of the icon.static booleanisFileImage(File file)Return whether the file is a known image file or not It is useImageIOto determine the file typestatic doublescaleToFit(Dimension src, Dimension dest)Return the scale value fromsrctodestproportionally
-
-
-
Method Detail
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage img, int width, int height, Object hint)
Return a scaled instance of the providedBufferedImage. Only a wrapper forgetScaledInstance(BufferedImage,int,int,Object,false)- Parameters:
img- the original image to be scaledwidth- target widthheight- target heighthint- one of the rendering hints that corresponds toRenderingHints.KEY_INTERPOLATION(e.g.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,RenderingHints.VALUE_INTERPOLATION_BILINEAR,RenderingHints.VALUE_INTERPOLATION_BICUBIC)- Returns:
- a scaled version of the original
BufferedImage - See Also:
getScaledInstance(BufferedImage,int,int,boolean,boolean),getScaledInstance(BufferedImage,int,int,Object,boolean)
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage img, int width, int height, boolean autoHint, boolean scaleFit)
Return a scaled instance of the providedBufferedImage.- Parameters:
img- the imagewidth- target widthheight- target heightautoHint- if scale factor > 0.5 use bicubic else use default.scaleFit- scale the image proportionally to fit the supplied width & height if the image is smaller than width and height then nothing change- Returns:
- new
BufferedImage - See Also:
getScaledInstance(BufferedImage,int,int,Object),getScaledInstance(BufferedImage,int,int,Object,boolean)
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage img, int width, int height, Object hint, boolean scaleFit)
Return a scaled instance of the providedBufferedImage.- Parameters:
img- the imagewidth- target widthheight- target heighthint- one of the rendering hints that corresponds toRenderingHints.KEY_INTERPOLATION(e.g.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,RenderingHints.VALUE_INTERPOLATION_BILINEAR,RenderingHints.VALUE_INTERPOLATION_BICUBIC)scaleFit- scale the image proportionally to fit the supplied width & height if the image is smaller than width and height then nothing change- Returns:
- new
BufferedImage - See Also:
getScaledInstance(BufferedImage,int,int,Object),getScaledInstance(BufferedImage,int,int,boolean,boolean),scaleToFit(Dimension,Dimension)
-
scaleToFit
public static double scaleToFit(Dimension src, Dimension dest)
Return the scale value fromsrctodestproportionally- Parameters:
src- source dimensiondest- destination dimension- Returns:
- the scale value
-
isFileImage
public static boolean isFileImage(File file)
Return whether the file is a known image file or not It is useImageIOto determine the file type- Parameters:
file- the file to be queried- Returns:
- true if it is know image file type, otherwise false
-
getFileSuffix
public static String getFileSuffix(File file)
Return file suffix portion of give file.- Parameters:
file- the file to be queried- Returns:
- suffix (eg: jpg,gif,etc) or null
-
iconToBufferedImage
public static BufferedImage iconToBufferedImage(Icon icon)
Returns aBufferedImagerepresentation of the icon.- Parameters:
icon- the icon- Returns:
BufferedImagerepresentation of the icon
-
createImageARGB
public static BufferedImage createImageARGB(Image src, boolean copy)
Returns aBufferedImagewith type ARGB based on the supplied source image- Parameters:
src-Imagecopy- if true copy the content of the source- Returns:
BufferedImage
-
createImageARGB
public static BufferedImage createImageARGB(int width, int height)
Returns aBufferedImagewith type ARGB based on the supplied param- Parameters:
width- the widthheight- the height- Returns:
BufferedImage
-
-