|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jomic.tools.ImageTools
public final class ImageTools
Utility methods for working with images.
Field Summary | |
---|---|
static int |
DISTINCT_ROTATIONS_COUNT
|
static java.lang.String |
GAUSSIAN_BLUR
|
static int |
ROTATE_CLOCKWISE
|
static int |
ROTATE_COUNTERCLOCKWISE
|
static int |
ROTATE_NONE
|
static int |
ROTATE_UPSIDE_DOWN
|
static java.lang.String |
SCALE_ACTUAL
|
static java.lang.String |
SCALE_FIT
|
static java.lang.String |
SCALE_HEIGHT
|
static java.lang.String |
SCALE_WIDTH
|
static java.lang.String |
THRESHOLD_BLUR
|
Method Summary | |
---|---|
void |
assertIsValidRotation(int rotation)
|
void |
assertIsValidScaleMode(java.lang.String scaleMode)
|
java.awt.image.RenderedImage |
createBrokenImage(int width,
int height,
java.awt.Color background,
java.awt.Color foreground)
Create image to represent a broken item. |
java.awt.image.RenderedImage |
createBusyImage(int width,
int height,
java.awt.Color background,
java.awt.Color foreground)
Create image to represent a busy image that is in process of being rendered. |
java.awt.image.BufferedImage |
createColorBox(int width,
int height,
java.awt.Color color)
Create a rectangle of a certain color. |
javax.imageio.stream.ImageInputStream |
createImageInputStream(java.io.File imageFile)
Same as ImageIO.createImageInputStream, but throws a FileNotFoundException if
imageFile cannot be found (instead of returning null ). |
double[] |
fillColorValues(java.awt.Color color,
java.awt.image.ColorModel colorModel)
Compute fill values for color when it should be used by the "border" operator
on an image with a ColorModel of colorModel . |
java.awt.image.BufferedImage |
getAsBufferedImage(java.awt.image.RenderedImage image)
Convert image to BufferedImage . |
javax.swing.ImageIcon |
getAsImageIcon(java.awt.image.RenderedImage image)
Convert image to ImageIcon . |
java.awt.image.BufferedImage |
getAsQuickBufferedImage(java.awt.image.RenderedImage image)
Get image in a form that can be processed quickly by most Java rendering operations. |
java.awt.image.RenderedImage |
getBluredImage(java.awt.image.RenderedImage image,
java.lang.String blurMode)
|
int |
getDeltaRotation(int oldRotation,
int newRotation)
Get relative Rotation needed to go from absolute rotation oldRotation to newRotation
. |
java.awt.Dimension |
getImageDimension(java.io.File imageFile)
|
java.awt.Dimension |
getImageDimension(javax.imageio.stream.ImageInputStream imageStream)
Get the image dimension of imageStream or null if no reader can be
found. |
java.lang.String |
getImageFormat(java.io.File imageFile)
Get the format of imageFile or null if no image reader is
available for it. |
java.lang.String |
getImageFormat(javax.imageio.stream.ImageInputStream imageStream)
Get the format of imageStream or null if no image stream or reader
is available. |
java.util.Map |
getImageProviderMap()
Get a map with the keys being an image file suffix, and the value being the name of the provider handling it. |
javax.imageio.ImageReader |
getImageReader(javax.imageio.stream.ImageInputStream imageStream)
Get an reader for in the image in imageStream . |
int |
getLeftRotation(int rotation)
|
int |
getNumBands(java.awt.image.RenderedImage image)
Like JAI's PlanarImage.getNumBands() , but also works on RenderedImage
. |
java.lang.String[] |
getPossibleBlurModes()
|
java.awt.RenderingHints |
getRenderingHints()
RenderingHints used by all render operations within ImageTools. |
int |
getRightRotation(int rotation)
|
java.awt.image.RenderedImage |
getRotatedImage(java.awt.image.RenderedImage image,
double angle)
|
java.awt.image.RenderedImage |
getRotatedImage(java.awt.image.RenderedImage image,
int rotation)
Rotate image in steps of 90 degrees. |
double |
getScaleToSqueeze(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
java.lang.String scaleMode)
Compute scale to squeeze into an area of size areaWidth xareaHeight
an image of size sourceWidth xsourceHeight . |
java.awt.image.RenderedImage |
getSqueezed(java.awt.image.RenderedImage source,
int areaWidth,
int areaHeight,
java.lang.String scaleMode)
Get a rescaled version of source that depending on scaleMode
possibly fits width and/or height while keeping proportions. |
java.awt.Dimension |
getSqueezedDimension(int areaWidth,
int areaHeight,
int sourceWidth,
int sourceHeight,
java.lang.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(java.lang.String imageFormat)
Yield true if imageFormat indicates a compressed reformat. |
boolean |
isImageFile(java.io.File file)
|
boolean |
isImageFile(java.lang.String filePathToCheck)
Yield true if filePathToCheck indicates an image file. |
boolean |
isImageSuffix(java.lang.String suffix)
|
boolean |
isLandscape(java.awt.Dimension size)
|
boolean |
isLandscape(int width,
int height)
|
boolean |
isLandscape(java.awt.image.RenderedImage image)
|
boolean |
isValidBlurMode(java.lang.String some)
|
boolean |
isValidRotation(int rotation)
|
boolean |
isValidScaleMode(java.lang.String mode)
|
java.awt.image.RenderedImage |
readImage(java.io.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 int DISTINCT_ROTATIONS_COUNT
public static final java.lang.String GAUSSIAN_BLUR
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 java.lang.String SCALE_ACTUAL
public static final java.lang.String SCALE_FIT
public static final java.lang.String SCALE_HEIGHT
public static final java.lang.String SCALE_WIDTH
public static final java.lang.String THRESHOLD_BLUR
Method Detail |
---|
public java.awt.image.BufferedImage getAsBufferedImage(java.awt.image.RenderedImage image)
image
to BufferedImage
. This is slow.
public javax.swing.ImageIcon getAsImageIcon(java.awt.image.RenderedImage image)
image
to ImageIcon
. This is slow.
public java.awt.image.BufferedImage getAsQuickBufferedImage(java.awt.image.RenderedImage image)
public java.awt.image.RenderedImage getBluredImage(java.awt.image.RenderedImage image, java.lang.String blurMode)
public int getDeltaRotation(int oldRotation, int newRotation)
oldRotation
to newRotation
.
public java.awt.Dimension getImageDimension(javax.imageio.stream.ImageInputStream imageStream) throws java.io.IOException
imageStream
or null
if no reader can be
found.
java.io.IOException
public java.awt.Dimension getImageDimension(java.io.File imageFile) throws java.io.IOException
java.io.IOException
public java.lang.String getImageFormat(javax.imageio.stream.ImageInputStream imageStream) throws java.io.IOException
imageStream
or null
if no image stream or reader
is available.
java.io.IOException
ImageIO.getImageReaders(java.lang.Object)
,
ImageIO.createImageInputStream(Object)
,
ImageReader.getFormatName()
public java.lang.String getImageFormat(java.io.File imageFile) throws java.io.IOException
imageFile
or null
if no image reader is
available for it.
java.io.IOException
ImageIO.getImageReaders(java.lang.Object)
,
ImageReader.getFormatName()
public java.util.Map getImageProviderMap()
public javax.imageio.ImageReader getImageReader(javax.imageio.stream.ImageInputStream imageStream)
imageStream
.
public int getLeftRotation(int rotation)
public int getNumBands(java.awt.image.RenderedImage image)
PlanarImage.getNumBands()
, but also works on RenderedImage
.
public java.lang.String[] getPossibleBlurModes()
getBluredImage(RenderedImage, String)
public java.awt.RenderingHints getRenderingHints()
public int getRightRotation(int rotation)
public java.awt.image.RenderedImage getRotatedImage(java.awt.image.RenderedImage image, double angle)
public java.awt.image.RenderedImage getRotatedImage(java.awt.image.RenderedImage image, int rotation)
rotation
- -1=counter clockwise, 0=no rotation, 1=clockwise, 2=upside downpublic double getScaleToSqueeze(int areaWidth, int areaHeight, int sourceWidth, int sourceHeight, java.lang.String scaleMode)
areaWidth
xareaHeight
an image of size sourceWidth
xsourceHeight
.
public java.awt.image.RenderedImage getSqueezed(java.awt.image.RenderedImage source, int areaWidth, int areaHeight, java.lang.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_HEIGHTpublic java.awt.Dimension getSqueezedDimension(int areaWidth, int areaHeight, int sourceWidth, int sourceHeight, java.lang.String scaleMode)
public boolean isCompressedImageFormat(java.lang.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(java.lang.String filePathToCheck)
true
if filePathToCheck
indicates an image file. The main
indicator is the suffix, additionally file names starting with "." are not considered images
even if the suffix would match. The latter ensures that files storing the resource fork in
ZIP archives created by Mac OS X's "compress" are ignored.
public boolean isImageFile(java.io.File file)
public boolean isImageSuffix(java.lang.String suffix)
public boolean isLandscape(int width, int height)
public boolean isLandscape(java.awt.Dimension size)
public boolean isLandscape(java.awt.image.RenderedImage image)
public boolean isValidBlurMode(java.lang.String some)
public boolean isValidRotation(int rotation)
public boolean isValidScaleMode(java.lang.String mode)
public static ImageTools instance()
public void assertIsValidRotation(int rotation)
public void assertIsValidScaleMode(java.lang.String scaleMode)
public java.awt.image.RenderedImage createBrokenImage(int width, int height, java.awt.Color background, java.awt.Color foreground)
public java.awt.image.RenderedImage createBusyImage(int width, int height, java.awt.Color background, java.awt.Color foreground)
public java.awt.image.BufferedImage createColorBox(int width, int height, java.awt.Color color)
public javax.imageio.stream.ImageInputStream createImageInputStream(java.io.File imageFile) throws java.io.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.
java.io.IOException
public double[] fillColorValues(java.awt.Color color, java.awt.image.ColorModel colorModel)
color
when it should be used by the "border" operator
on an image with a ColorModel of colorModel
.
public java.awt.image.RenderedImage readImage(java.io.File imageFile) throws java.io.IOException
imageFile
.
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |