|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.ImageUtils
org.tbee.swing.ImageUtils
public class ImageUtils
This is a small class providing some basic and very often used image functions associated with Swing. For example the gradient image which is often used in conjunction with JPanelWithBackground.
| Field Summary | |
|---|---|
static int |
DIAGONAL_LTBR
|
static int |
DIAGONAL_RTBL
|
static int |
HORIZONTAL
|
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
static int |
VERTICAL
|
| Constructor Summary | |
|---|---|
ImageUtils()
|
|
| Method Summary | |
|---|---|
static java.awt.image.BufferedImage |
addBlur(java.awt.image.BufferedImage image)
Add a blur over the image (using GaussianBlur). |
static java.awt.image.BufferedImage |
addGaussianBlur(java.awt.image.BufferedImage image,
double radius)
Add a blur over the image (using linear blur). |
static java.awt.image.BufferedImage |
addLinearBlur(java.awt.image.BufferedImage image,
int blurIndex)
Add a blur over the image (using linear blur). |
static java.awt.image.BufferedImage |
addMargin(java.awt.image.BufferedImage image,
int margin)
This method is used to easy add a margin for blurring. |
static java.awt.image.BufferedImage |
addNoise(java.awt.image.BufferedImage image)
add a bit of noise to the whole image |
static java.awt.image.BufferedImage |
addNoise(double noiseFactor,
java.awt.image.BufferedImage image)
add a bit of noise to the whole image |
static java.awt.image.BufferedImage |
addNoise(double noiseFactor,
int x,
int y,
int width,
int height,
java.awt.image.BufferedImage image)
add a bit of noise |
static java.awt.image.BufferedImage |
addReflectionImage(java.awt.image.BufferedImage image)
|
static java.awt.image.BufferedImage |
addReflectionImage(java.awt.image.BufferedImage image,
float compressionFactor,
int shadowOffset)
Create a copy of the image with or without a shadow. |
static void |
addText(java.awt.image.BufferedImage image,
javax.swing.JLabel label)
Add a contrasted text to an image |
static void |
addText(java.awt.Graphics2D graphics2D,
double x,
double y,
java.awt.font.TextLayout lTitle,
java.awt.Color foreground,
java.awt.Color background)
Draw a contrasted text |
static java.awt.image.BufferedImage |
brighter(java.awt.image.BufferedImage image)
|
static java.awt.image.BufferedImage |
brighter(java.awt.image.BufferedImage image,
int times)
make brigher Note: the image itself is altered, use createBufferedImage to work on a copy. |
static java.awt.image.BufferedImage |
captureScreen()
Capture the current screen |
static java.awt.image.BufferedImage |
createBufferedImage(java.awt.Image image)
Create a buffered image from a regular image |
static java.awt.image.BufferedImage |
createBufferedImage(int width,
int height)
Although any BufferedImage can be painted, it is wise to created images that are compatible with the current screen device. |
static java.awt.image.BufferedImage |
createBufferedImage(int width,
int height,
int transparency)
Although any BufferedImage can be painted, it is wise to created images that are compatible with the current screen device. |
static java.awt.Image |
createDisabled(java.awt.image.BufferedImage image)
Return a new image that appears disabled |
static java.awt.image.BufferedImage |
createGradientImage(java.awt.Color color1,
java.awt.Color color2,
java.awt.Color color3,
int direction)
|
static java.awt.image.BufferedImage |
createGradientImage(java.awt.Color color1,
java.awt.Color color2,
java.awt.Color color3,
int direction,
int width,
int height)
|
static java.awt.image.BufferedImage |
createGradientImage(java.awt.Color color1,
java.awt.Color color2,
int direction)
|
static java.awt.image.BufferedImage |
createGradientImage(java.awt.Color color1,
java.awt.Color color2,
int direction,
int width,
int heigth)
|
static java.awt.Image |
createImage(int[] pixels,
int width,
int height)
Create image from pixels |
static java.awt.image.BufferedImage |
createImageFromComponent(java.awt.Component component)
Create a buffered image from a component |
static java.awt.image.BufferedImage |
createImageFromIcon(javax.swing.Icon icon)
Create a buffered image from a component |
static java.awt.image.BufferedImage |
createJLabelImage(javax.swing.JLabel label,
int margin,
boolean blur)
Deprecated. use the method which has a double blur parameter |
static java.awt.image.BufferedImage |
createJLabelImage(javax.swing.JLabel label,
int margin,
double blur)
Convert JLabel to Image |
static int[] |
createPixels(java.awt.image.BufferedImage bufferedImage)
Convert a buffered image into an array of rows of pixels The grabPixels method of the PixelGrabber class extracts the pixel data from an Image object into a one-dimensional array of type int. |
static java.awt.image.BufferedImage |
createReflectionImage(java.awt.image.BufferedImage image)
|
static java.awt.image.BufferedImage |
createReflectionImage(java.awt.image.BufferedImage image,
float compressionFactor)
Create a copy of the image with or without a shadow. |
static java.awt.image.BufferedImage |
createShadedImage(java.awt.image.BufferedImage image,
boolean addShade)
Create a copy of the image with or without a shadow. |
static java.awt.image.BufferedImage |
createShadedImage(java.awt.image.BufferedImage image,
int shadeOffset)
Create a copy of the image with a shadow. |
static java.awt.image.BufferedImage |
darker(java.awt.image.BufferedImage image)
make darker Note: the image itself is altered, use createBufferedImage to work on a copy. |
static void |
drawTextWithGlow(java.lang.String text,
java.awt.Graphics g,
java.awt.Font font,
int glowSize,
java.awt.Color foreground,
java.awt.Color glow,
float opacity)
Draw a glowing text on an image |
static java.awt.image.BufferedImage |
flipHorizontal(java.awt.image.BufferedImage image)
|
static java.awt.image.BufferedImage |
flipVertical(java.awt.image.BufferedImage image)
|
static java.awt.image.ConvolveOp |
getGaussianBlurOp(double stddev)
Get a ConvolveOp that blurs |
static java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> |
getHighQualityRenderingHints()
|
static java.awt.image.ConvolveOp |
getLinearBlurOp(int size)
Get a ConvolveOp that blurs |
static java.awt.image.BufferedImage |
makeColorTransparent(java.awt.image.BufferedImage image,
java.awt.Color color)
This method erases a color form an image with a completely transparency color and thus effectively erasing it Note: the image itself is altered, use createBufferedImage to work on a copy. |
static void |
makeGlow(int[] pixels,
int width,
int height)
Add a glow to an image http://www.curious-creature.org/2007/02/20/fast-image-processing-with-jogl Does not work at this time |
static java.awt.image.BufferedImage |
makeGray(java.awt.image.BufferedImage image)
make gray Note: the image itself is altered, use createBufferedImage to work on a copy. |
static java.awt.image.BufferedImage |
morph(java.awt.image.BufferedImage from,
java.awt.image.BufferedImage to,
double percentage)
|
static void |
paintReflectionImage(java.awt.image.BufferedImage canvasImage,
java.awt.image.BufferedImage sourceImage,
float compressionFactor,
int offsetX,
int offsetY)
Paint the reflection onto the canvas |
static java.awt.image.BufferedImage |
putInPerspective(java.awt.image.BufferedImage image)
|
static java.awt.image.BufferedImage |
readThumbnailMaintainRatio(java.io.File imageFile,
int maxWidth,
int maxHeight)
|
static java.awt.image.BufferedImage |
removeMargin(java.awt.image.BufferedImage image,
int margin)
This method is used to easy add a margin for blurring. |
static java.awt.image.BufferedImage |
replaceColor(java.awt.image.BufferedImage image,
java.awt.Color originalColor,
java.awt.Color newColor)
This method replace a color from an image with another color Note: the image itself is returned, use createBufferedImage to work on a copy. |
static java.awt.image.BufferedImage |
resize(java.awt.image.BufferedImage image,
double scale)
Resize by scale |
static java.awt.image.BufferedImage |
resize(java.awt.image.BufferedImage image,
double scaleX,
double scaleY)
Resize by scale |
static java.awt.image.BufferedImage |
resize(java.awt.image.BufferedImage image,
int width,
int height)
Resize to W & H |
static java.awt.image.BufferedImage |
rotate90(java.awt.image.BufferedImage image,
boolean clockwise)
|
static java.awt.image.BufferedImage |
textWithGlow(java.lang.String text,
java.awt.Font font,
int glowSize,
java.awt.Color foreground,
java.awt.Color glow,
float opacity)
Create an transparent image with glowing text |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SOURCECODE_VERSION
public static final int HORIZONTAL
public static final int VERTICAL
public static final int DIAGONAL_LTBR
public static final int DIAGONAL_RTBL
| Constructor Detail |
|---|
public ImageUtils()
| Method Detail |
|---|
public static java.awt.image.BufferedImage createBufferedImage(int width,
int height)
public static java.awt.image.BufferedImage createBufferedImage(int width,
int height,
int transparency)
Transparency
public static java.awt.image.BufferedImage createJLabelImage(javax.swing.JLabel label,
int margin,
double blur)
label - this labels contains the text, font, color (foreground) and contrast color (background)margin - blur - 0.5 is a good value
public static java.awt.image.BufferedImage createJLabelImage(javax.swing.JLabel label,
int margin,
boolean blur)
public static void addText(java.awt.image.BufferedImage image,
javax.swing.JLabel label)
image - image to add the text tolabel - this labels contains the text, font, color (foreground) and
contrast color (background)
public static void addText(java.awt.Graphics2D graphics2D,
double x,
double y,
java.awt.font.TextLayout lTitle,
java.awt.Color foreground,
java.awt.Color background)
image - image to add the text tolabel - this labels contains the text, font, color (foreground) and
contrast color (background)
public static java.awt.image.BufferedImage textWithGlow(java.lang.String text,
java.awt.Font font,
int glowSize,
java.awt.Color foreground,
java.awt.Color glow,
float opacity)
text - font - glowSize - foreground - glow - opacity -
public static void drawTextWithGlow(java.lang.String text,
java.awt.Graphics g,
java.awt.Font font,
int glowSize,
java.awt.Color foreground,
java.awt.Color glow,
float opacity)
text - g - font - glowSize - foreground - glow - opacity -
public static java.awt.image.BufferedImage createGradientImage(java.awt.Color color1,
java.awt.Color color2,
int direction)
color1 - color2 - direction -
public static java.awt.image.BufferedImage createGradientImage(java.awt.Color color1,
java.awt.Color color2,
int direction,
int width,
int heigth)
color1 - color2 - direction - width - of the to be generated imageheight - of the to be generated image
public static java.awt.image.BufferedImage createGradientImage(java.awt.Color color1,
java.awt.Color color2,
java.awt.Color color3,
int direction)
color1 - color2 - color3 - direction -
public static java.awt.image.BufferedImage createGradientImage(java.awt.Color color1,
java.awt.Color color2,
java.awt.Color color3,
int direction,
int width,
int height)
color1 - color2 - color3 - direction - width - of the to be generated imageheight - of the to be generated image
public static java.awt.image.BufferedImage addNoise(java.awt.image.BufferedImage image)
image - the image to add noise tonoiseFactor - how much noise should be added, something between 3.0 and 10.0 is usually a good value.
public static java.awt.image.BufferedImage addNoise(double noiseFactor,
java.awt.image.BufferedImage image)
noiseFactor - how much noise should be added, something between 3.0 and 10.0 is usually a good value.image - the image to add noise to
public static java.awt.image.BufferedImage addNoise(double noiseFactor,
int x,
int y,
int width,
int height,
java.awt.image.BufferedImage image)
noiseFactor - how much noise should be added, something between 3.0 and 10.0 is usually a good value.x - y - width - height - image - the image to add noise to
public static java.awt.image.BufferedImage addLinearBlur(java.awt.image.BufferedImage image,
int blurIndex)
public static java.awt.image.ConvolveOp getLinearBlurOp(int size)
size -
public static java.awt.image.BufferedImage addGaussianBlur(java.awt.image.BufferedImage image,
double radius)
public static java.awt.image.ConvolveOp getGaussianBlurOp(double stddev)
size -
public static java.awt.image.BufferedImage addBlur(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage addMargin(java.awt.image.BufferedImage image,
int margin)
public static java.awt.image.BufferedImage removeMargin(java.awt.image.BufferedImage image,
int margin)
public static java.awt.image.BufferedImage replaceColor(java.awt.image.BufferedImage image,
java.awt.Color originalColor,
java.awt.Color newColor)
public static java.awt.image.BufferedImage makeColorTransparent(java.awt.image.BufferedImage image,
java.awt.Color color)
public static java.awt.image.BufferedImage makeGray(java.awt.image.BufferedImage image)
public static java.awt.Image createDisabled(java.awt.image.BufferedImage image)
image -
public static java.awt.image.BufferedImage brighter(java.awt.image.BufferedImage image,
int times)
public static java.awt.image.BufferedImage brighter(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage darker(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage createShadedImage(java.awt.image.BufferedImage image,
boolean addShade)
image - addShade -
public static java.awt.image.BufferedImage createShadedImage(java.awt.image.BufferedImage image,
int shadeOffset)
image - shadeOffset -
public static java.awt.image.BufferedImage putInPerspective(java.awt.image.BufferedImage image)
public static void paintReflectionImage(java.awt.image.BufferedImage canvasImage,
java.awt.image.BufferedImage sourceImage,
float compressionFactor,
int offsetX,
int offsetY)
canvasImage - sourceImage - compressionFactor - offsetX - offsetY -
public static java.awt.image.BufferedImage createReflectionImage(java.awt.image.BufferedImage image,
float compressionFactor)
image - compressionFactor - how much of the original image is drawn as the shadow (2=half)
public static java.awt.image.BufferedImage createReflectionImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage addReflectionImage(java.awt.image.BufferedImage image,
float compressionFactor,
int shadowOffset)
image - compressionFactor - the amount with which the image is reduced (2 = half)shadowOffset - number of pixels the shadow is placed away from the original (5 is a good value)
public static java.awt.image.BufferedImage addReflectionImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage flipVertical(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage flipHorizontal(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage rotate90(java.awt.image.BufferedImage image,
boolean clockwise)
public static java.awt.image.BufferedImage morph(java.awt.image.BufferedImage from,
java.awt.image.BufferedImage to,
double percentage)
public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage image,
double scale)
public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage image,
double scaleX,
double scaleY)
public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage image,
int width,
int height)
image - width - height -
public static void makeGlow(int[] pixels,
int width,
int height)
public static java.awt.image.BufferedImage createBufferedImage(java.awt.Image image)
public static java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getHighQualityRenderingHints()
public static java.awt.image.BufferedImage createImageFromComponent(java.awt.Component component)
component - Component
public static java.awt.image.BufferedImage createImageFromIcon(javax.swing.Icon icon)
icon - Component
public static int[] createPixels(java.awt.image.BufferedImage bufferedImage)
bufferedImage -
public static java.awt.Image createImage(int[] pixels,
int width,
int height)
pixels - width - height -
public static java.awt.image.BufferedImage captureScreen()
public static java.awt.image.BufferedImage readThumbnailMaintainRatio(java.io.File imageFile,
int maxWidth,
int maxHeight)
throws java.io.IOException
imageFile - maxWidth - maxHeight -
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||