|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jomic.tools.ImageTools
public final class ImageTools
Utility methods for working with images.
| Field Summary | |
|---|---|
static String |
DIFFERENCE_BLUR
|
static int |
DISTINCT_ROTATIONS_COUNT
|
static int |
ROTATE_CLOCKWISE
|
static int |
ROTATE_COUNTERCLOCKWISE
|
static int |
ROTATE_NONE
|
static int |
ROTATE_UPSIDE_DOWN
|
static String |
SCALE_ACTUAL
|
static String |
SCALE_FIT
|
static String |
SCALE_HEIGHT
|
static String |
SCALE_WIDTH
|
static String |
THRESHOLD_BLUR
|
| Method Summary | |
|---|---|
void |
assertIsValidRotation(int rotation)
|
void |
assertIsValidScaleMode(String scaleMode)
|
RenderedImage |
combinedImage(RenderedImage leftImage,
RenderedImage rightImage)
Get an image that contains leftImage and rightImage. |
RenderedImage |
combinedImage(RenderedImage leftImage,
RenderedImage rightImage,
Color background)
Get an image that contains leftImage and rightImage, with possible
blank pixels filled with background color.. |
RenderedImage |
convertedToRGB(RenderedImage image)
Gets a 24 bit version of image. |
RenderedImage |
createBrokenImage(int width,
int height,
Color background,
Color foreground)
Create image to represent a broken item. |
RenderedImage |
createBusyImage(int width,
int height,
Color background,
Color foreground)
Create image to represent a busy image that is in process of being rendered. |
BufferedImage |
createColorBox(int width,
int height,
Color color)
Create a rectangle of a certain color. |
javax.media.jai.LookupTableJAI |
createGreyScaleLookupTableJAI(int bits)
Create a lookup table to convert a grey scale image using bits to a sRGB image. |
ImageInputStream |
createImageInputStream(File imageFile)
Same as ImageIO.createImageInputStream, but throws a FileNotFoundException if
imageFile cannot be found (instead of returning null). |
double[] |
fillColorValues(Color color,
ColorModel colorModel)
Compute fill values for color when it should be used by the "border" operater
on an image with a ColorModel of colorModel. |
BufferedImage |
getAsBufferedImage(RenderedImage image)
Convert image to BufferedImage. |
ImageIcon |
getAsImageIcon(RenderedImage image)
Convert image to ImageIcon. |
RenderedImage |
getBluredImage(RenderedImage image,
String blurMode)
|
int |
getDeltaRotation(int oldRotation,
int newRotation)
Get relative Rotation needed to go from absolute rotation oldRotation to newRotation
. |
Dimension |
getImageDimension(File imageFile)
|
Dimension |
getImageDimension(ImageInputStream imageStream)
Get the image dimension of imageStream or null if no reader can be
found. |
String |
getImageFormat(File imageFile)
Get the format of imageFile or null if no image reader is
available for it. |
String |
getImageFormat(ImageInputStream imageStream)
Get the format of imageStream or null if no image stream or reader
is available. |
Map |
getImageProviderMap()
Get a map with the keys being an image file suffix, and the value being the name of the provider handling it. |
ImageReader |
getImageReader(ImageInputStream imageStream)
Get an reader for in the image in imageStream. |
int |
getLeftRotation(int rotation)
|
int |
getNumBands(RenderedImage image)
Like PlanarImage.getNumBands(), but also works on RenderedImage. |
String[] |
getPossibleBlurModes()
|
int |
getRightRotation(int rotation)
|
RenderedImage |
getRotatedImage(RenderedImage image,
float radians)
|
RenderedImage |
getRotatedImage(RenderedImage image,
int rotation)
Rotate image in steps of 90 degrees. |
double |
getScaleToSqueeze(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
String scaleMode)
Compute scale to squeeze into an area of size areaWidthxareaHeight
an image of size sourceWidthxsourceHeight. |
RenderedImage |
getSqueezed(RenderedImage source,
int areaWidth,
int areaHeight,
String scaleMode)
Get a rescaled version of source that depending on scaleMode
possibly fits width and/or height while keeping proportions. |
Dimension |
getSqueezedDimension(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
String scaleMode)
Get the size of the actual area used by a sourceWidth x sourceHeight image squeezed in an areaWidth x areaHeight area. |
static ImageTools |
instance()
Get accessor to unique instance. |
boolean |
isCompressedImageFormat(String imageFormat)
Yield true if imageFormat indicates a compressed reformat. |
boolean |
isImageFile(File file)
|
boolean |
isImageFile(String fileName)
|
boolean |
isImageSuffix(String suffix)
|
boolean |
isLandscape(Dimension size)
|
boolean |
isLandscape(int width,
int height)
|
boolean |
isLandscape(RenderedImage image)
|
boolean |
isValidBlurMode(String some)
|
boolean |
isValidRotation(int rotation)
|
boolean |
isValidScaleMode(String mode)
|
void |
loadImageToMemory(RenderedImage image)
Attempty to preload whole image in memory. |
RenderedImage |
readImage(File imageFile)
Read the specified imageFile. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DIFFERENCE_BLUR
public static final int DISTINCT_ROTATIONS_COUNT
public static final int ROTATE_CLOCKWISE
public static final int ROTATE_COUNTERCLOCKWISE
public static final int ROTATE_NONE
public static final int ROTATE_UPSIDE_DOWN
public static final String SCALE_ACTUAL
public static final String SCALE_FIT
public static final String SCALE_HEIGHT
public static final String SCALE_WIDTH
public static final String THRESHOLD_BLUR
| Method Detail |
|---|
public BufferedImage getAsBufferedImage(RenderedImage image)
image to BufferedImage. This is slow.
public ImageIcon getAsImageIcon(RenderedImage image)
image to ImageIcon. This is slow.
public RenderedImage getBluredImage(RenderedImage image,
String blurMode)
public int getDeltaRotation(int oldRotation,
int newRotation)
oldRotation to newRotation
.
public Dimension getImageDimension(ImageInputStream imageStream)
throws IOException
imageStream or null if no reader can be
found.
IOException
public Dimension getImageDimension(File imageFile)
throws IOException
IOException
public String getImageFormat(ImageInputStream imageStream)
throws IOException
imageStream or null if no image stream or reader
is available.
IOExceptionImageIO.getImageReaders(java.lang.Object),
ImageIO.createImageInputStream(Object),
ImageReader.getFormatName()
public String getImageFormat(File imageFile)
throws IOException
imageFile or null if no image reader is
available for it.
IOExceptionImageIO.getImageReaders(java.lang.Object),
ImageReader.getFormatName()public Map getImageProviderMap()
public ImageReader getImageReader(ImageInputStream imageStream)
imageStream.
public int getLeftRotation(int rotation)
public int getNumBands(RenderedImage image)
PlanarImage.getNumBands(), but also works on RenderedImage.
PlanarImage.getNumBands()public String[] getPossibleBlurModes()
getBluredImage(RenderedImage, String)public int getRightRotation(int rotation)
public RenderedImage getRotatedImage(RenderedImage image,
float radians)
public RenderedImage getRotatedImage(RenderedImage image,
int rotation)
rotation - -1=counter clockwise, 0=no rotation, 1=clockwise, 2=upside down
public double getScaleToSqueeze(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
String scaleMode)
areaWidthxareaHeight
an image of size sourceWidthxsourceHeight.
public RenderedImage getSqueezed(RenderedImage source,
int areaWidth,
int areaHeight,
String scaleMode)
source that depending on scaleMode
possibly fits width and/or height while keeping proportions.
scaleMode - one of: SCALE_ACTUAL, SCALE_FIT, SCALE_WIDTH, SCALE_HEIGHT
public Dimension getSqueezedDimension(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
String scaleMode)
public boolean isCompressedImageFormat(String imageFormat)
true if imageFormat indicates a compressed reformat. Images
in such formats will not shrink significantly by compressing them using for example ZIP.
getImageFormat(ImageInputStream)public boolean isImageFile(String fileName)
public boolean isImageFile(File file)
public boolean isImageSuffix(String suffix)
public boolean isLandscape(int width,
int height)
public boolean isLandscape(Dimension size)
public boolean isLandscape(RenderedImage image)
public boolean isValidBlurMode(String some)
public boolean isValidRotation(int rotation)
public boolean isValidScaleMode(String mode)
public static ImageTools instance()
public void assertIsValidRotation(int rotation)
public void assertIsValidScaleMode(String scaleMode)
public RenderedImage combinedImage(RenderedImage leftImage,
RenderedImage rightImage)
leftImage and rightImage.
public RenderedImage combinedImage(RenderedImage leftImage,
RenderedImage rightImage,
Color background)
leftImage and rightImage, with possible
blank pixels filled with background color..
public RenderedImage convertedToRGB(RenderedImage image)
image. If the image already was 24 bit, do nothing.
This is most useful to load a index image like GIFs, and combine them with images of any
other format.
public RenderedImage createBrokenImage(int width,
int height,
Color background,
Color foreground)
public RenderedImage createBusyImage(int width,
int height,
Color background,
Color foreground)
public BufferedImage createColorBox(int width,
int height,
Color color)
public javax.media.jai.LookupTableJAI createGreyScaleLookupTableJAI(int bits)
bits to a sRGB image.
public ImageInputStream createImageInputStream(File imageFile)
throws IOException
FileNotFoundException if
imageFile cannot be found (instead of returning null). Why the
original does not work that way already is beyond me.Note that a non-image (such as a text file) still returns proper stream.
IOException
public double[] fillColorValues(Color color,
ColorModel colorModel)
color when it should be used by the "border" operater
on an image with a ColorModel of colorModel.
public void loadImageToMemory(RenderedImage image)
public RenderedImage readImage(File imageFile)
throws IOException
imageFile.
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||