kiyut.citra 3.7

kiyut.citra.util
Class ImageUtilities

java.lang.Object
  extended by kiyut.citra.util.ImageUtilities

public class ImageUtilities
extends Object

Image utilitis class. It provides provides static methods for manipulating Images

Author:
Kiyut

Constructor Summary
ImageUtilities()
           
 
Method Summary
static BufferedImage createImageARGB(Image src, boolean copy)
          Returns a BufferedImage with type ARGB based on the supplied source image
static BufferedImage createImageARGB(int width, int height)
          Returns a BufferedImage with type ARGB based on the supplied param
static String getFileSuffix(File file)
          Return file suffix portion of give file.
static BufferedImage getScaledInstance(BufferedImage img, int width, int height, boolean autoHint, boolean scaleFit)
          Return a scaled instance of the provided BufferedImage.
static BufferedImage getScaledInstance(BufferedImage img, int width, int height, Object hint)
          Return a scaled instance of the provided BufferedImage.
static BufferedImage getScaledInstance(BufferedImage img, int width, int height, Object hint, boolean scaleFit)
          Return a scaled instance of the provided BufferedImage.
static BufferedImage iconToBufferedImage(Icon icon)
          Returns a BufferedImage representation of the icon.
static boolean isFileImage(File file)
          Return whether the file is a known image file or not It is use ImageIO to determine the file type
static double scaleToFit(Dimension src, Dimension dest)
          Return the scale value from src to dest proportionally
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtilities

public ImageUtilities()
Method Detail

getScaledInstance

public static BufferedImage getScaledInstance(BufferedImage img,
                                              int width,
                                              int height,
                                              Object hint)
Return a scaled instance of the provided BufferedImage. Only a wrapper for getScaledInstance(BufferedImage,int,int,Object,false)

Parameters:
img - the original image to be scaled
width - target width
height - target height
hint - one of the rendering hints that corresponds to RenderingHints.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 provided BufferedImage.

Parameters:
img - the image
width - target width
height - target height
autoHint - 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 provided BufferedImage.

Parameters:
img - the image
width - target width
height - target height
hint - one of the rendering hints that corresponds to RenderingHints.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 from src to dest proportionally

Parameters:
src - source dimension
dest - 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 use ImageIO to 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 a BufferedImage representation of the icon.

Parameters:
icon - the icon
Returns:
BufferedImage representation of the icon

createImageARGB

public static BufferedImage createImageARGB(Image src,
                                            boolean copy)
Returns a BufferedImage with type ARGB based on the supplied source image

Parameters:
src - Image
copy - if true copy the content of the source
Returns:
BufferedImage

createImageARGB

public static BufferedImage createImageARGB(int width,
                                            int height)
Returns a BufferedImage with type ARGB based on the supplied param

Parameters:
width - the width
height - the height
Returns:
BufferedImage

kiyut.citra 3.7