Package ca.cgjennings.graphics
Class ImageUtilities
- java.lang.Object
-
- ca.cgjennings.graphics.ImageUtilities
-
public final class ImageUtilities extends java.lang.Object
Utility methods for creating and converting images, icons, and other graphics. The functionality includes: creating and converting images in certain common formats (particularly the integer (A)RGB formats that the filters in the graphics filters package are optimized for), converting icons to images, adjusting the size of icons, and applying common filter effects to icon images, creating customCursor
s, applying common filters to images, copying images, and adjusting the margins of images (padding, trimming, centreing), computing the ideal scale for an image to fit it within or over a given area, and resampling (resizing) images at high quality.- Since:
- 2.1
- Author:
- Chris Jennings
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.awt.image.BufferedImage
alphaComposite(java.awt.image.BufferedImage source, float opacity)
Return a version of this image with an overall transparency change.static java.awt.image.BufferedImage
center(java.awt.image.BufferedImage source, int width, int height)
Returns an image that centres a source image over a new image of a given size.static java.awt.image.BufferedImage
copy(java.awt.image.BufferedImage source)
Returns a copy of the image.static java.awt.image.BufferedImage
createCompatibleIntARGBFormat(java.awt.image.BufferedImage im)
Creates a new image the same size asim
which is in TYPE_INT_ARGB format.static java.awt.image.BufferedImage
createCompatibleIntRGBFormat(java.awt.image.BufferedImage im)
Creates a new image the same size asim
which is in either TYPE_INT_RGB or TYPE_INT_ARGB format depending on whether im is opaque.static java.awt.image.BufferedImage
createCompatibleIntRGBFormat(java.awt.image.BufferedImage im, int width, int height)
Creates a new image with the specified size which is in either TYPE_INT_RGB or TYPE_INT_ARGB format depending on whether im is opaque.static java.awt.Cursor
createCustomCursor(java.awt.image.BufferedImage image, int hotspotX, int hotspotY)
static java.awt.Cursor
createCustomCursor(java.awt.Toolkit toolkit, java.awt.image.BufferedImage image, int hotspotX, int hotspotY, java.lang.String name)
static javax.swing.Icon
createDesaturatedIcon(javax.swing.Icon src)
Returns a greyscale version of an icon.static javax.swing.Icon
createDisabledIcon(javax.swing.Icon src)
Returns a disabled version of an icon.static java.awt.image.BufferedImage
createDisabledImage(java.awt.image.BufferedImage src)
Returns a disabled version of an image.static javax.swing.Icon
createGhostedIcon(javax.swing.Icon src)
Returns a ghosted version of an icon.static javax.swing.Icon
createIconForSize(java.awt.image.BufferedImage image, int size)
Creates an icon fromimage
that is constrained tosize
bysize
pixels.static java.awt.image.BufferedImage
desaturate(java.awt.image.BufferedImage src)
Returns a greyscale version of an image.static javax.swing.Icon
ensureIconHasSize(javax.swing.Icon icon, int size)
Ensures that the supplied icon has the specified size.static java.awt.image.BufferedImage
ensureImageHasAlphaChannel(java.awt.image.BufferedImage im)
Returns a version of an image that includes an alpha channel.static java.awt.image.BufferedImage
ensureImageHasType(java.awt.image.BufferedImage im, int type)
If im does not use the specified pixel format, an equivalent image in that format is returned.static java.awt.image.BufferedImage
ensureIntRGBFormat(java.awt.Image image)
If im is not in an integer (A)RGB format, returns a new, equivalent image in an integer RGB format.static java.awt.image.BufferedImage
ensurePremultipliedFormat(java.awt.image.BufferedImage im)
Returns a version of an image that is in an integer (A)RGB format.static java.awt.image.BufferedImage
flip(java.awt.image.BufferedImage source, boolean horiz, boolean vert)
Returns a mirrored version of the source image.static java.awt.image.BufferedImage
iconToImage(javax.swing.Icon i)
Returns the visual content of an icon as an image.static double
idealBoundingScaleForImage(double idealWidth, double idealHeight, double imageWidth, double imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension.static float
idealBoundingScaleForImage(float idealWidth, float idealHeight, float imageWidth, float imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension.static float
idealBoundingScaleForImage(int idealWidth, int idealHeight, int imageWidth, int imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension.static double
idealCoveringScaleForImage(double idealWidth, double idealHeight, double imageWidth, double imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension.static float
idealCoveringScaleForImage(float idealWidth, float idealHeight, float imageWidth, float imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension.static float
idealCoveringScaleForImage(int idealWidth, int idealHeight, int imageWidth, int imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension.static java.awt.image.BufferedImage
imageToBufferedImage(java.awt.Image image)
Returns aBufferedImage
that is equivalent to a specifiedImage
.static java.awt.image.BufferedImage
invert(java.awt.image.BufferedImage source)
Returns a copy of the source image with the colour values inverted.static boolean
isOpaque(java.awt.image.BufferedImage bi)
Returnstrue
if every pixel in this image is fully opaque.static java.awt.image.BufferedImage
merge(java.awt.image.BufferedImage... images)
Draws a series of images overtop of each other.static java.awt.image.BufferedImage
pad(java.awt.image.BufferedImage source, int top, int left, int bottom, int right)
Returns an image that is identical to a source image except that it is padded by blank pixels around the outside.static java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage src, float factor)
Resample an image by a scaling factor, at a high level of quality.static java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage src, float factor, boolean multipass, java.lang.Object finalPassHint, java.lang.Object intermediateHint)
static java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage src, int width, int height)
Resample an image to a specified size, at a high level of quality.static java.awt.image.BufferedImage
resample(java.awt.image.BufferedImage src, int width, int height, boolean multipass, java.lang.Object finalPassHint, java.lang.Object intermediateHint)
Resample an image.static java.awt.image.BufferedImage
trim(java.awt.image.BufferedImage sourceImage)
Create a trimmed version of the source image that excludes fully transparent (alpha=0) rows and columns around the image's edges.static java.awt.Image
waitForImage(java.awt.Image im)
Waits for an image to load.
-
-
-
Method Detail
-
createCompatibleIntRGBFormat
public static java.awt.image.BufferedImage createCompatibleIntRGBFormat(java.awt.image.BufferedImage im)
Creates a new image the same size asim
which is in either TYPE_INT_RGB or TYPE_INT_ARGB format depending on whether im is opaque.- Parameters:
im
- the image to create a new image for- Returns:
- a new image compatible with im but guaranteed to use an 8-bit RGB format
-
createCompatibleIntRGBFormat
public static java.awt.image.BufferedImage createCompatibleIntRGBFormat(java.awt.image.BufferedImage im, int width, int height)
Creates a new image with the specified size which is in either TYPE_INT_RGB or TYPE_INT_ARGB format depending on whether im is opaque.- Parameters:
im
- the image to create a new image for- Returns:
- a new image compatible with im but guaranteed to use an 8-bit RGB format
-
createCompatibleIntARGBFormat
public static java.awt.image.BufferedImage createCompatibleIntARGBFormat(java.awt.image.BufferedImage im)
Creates a new image the same size asim
which is in TYPE_INT_ARGB format.- Parameters:
im
- the image to create a new image for- Returns:
- a new image compatible with im but guaranteed to use 8-bit ARGB format
-
ensureIntRGBFormat
public static java.awt.image.BufferedImage ensureIntRGBFormat(java.awt.Image image)
If im is not in an integer (A)RGB format, returns a new, equivalent image in an integer RGB format. If im is already in an integer RGB format, returns the original image.- Parameters:
im
- the non-null image to be provided in integer RGB format- Returns:
- the original image, or a copy converted to a suitable format
-
ensureImageHasAlphaChannel
public static java.awt.image.BufferedImage ensureImageHasAlphaChannel(java.awt.image.BufferedImage im)
Returns a version of an image that includes an alpha channel. If the source image has an alpha channel, it is returned. Otherwise, a copy is returned.- Parameters:
im
- the image to check- Returns:
- the original image, or a copy that includes an alpha channel
-
ensureImageHasType
public static java.awt.image.BufferedImage ensureImageHasType(java.awt.image.BufferedImage im, int type)
If im does not use the specified pixel format, an equivalent image in that format is returned. If im is already in the specified format, it is returned unchanged.- Parameters:
im
- the image to be provided in the specified formattype
- theBufferedImage.TYPE_*
value for the desired format- Returns:
- the original image, or a copy converted to the requested format
-
ensurePremultipliedFormat
public static java.awt.image.BufferedImage ensurePremultipliedFormat(java.awt.image.BufferedImage im)
Returns a version of an image that is in an integer (A)RGB format. If the source includes an alpha channel, the returned image will use a premultiplied image type.- Parameters:
im
- the image to be provided in the specified format- Returns:
- the original image, or a copy in an integer (A)RGB format, with premultiplied alpha if appropriate
-
createCustomCursor
@Deprecated public static java.awt.Cursor createCustomCursor(java.awt.image.BufferedImage image, int hotspotX, int hotspotY)
Deprecated.Defines a new custom cursor for use with the defaultToolkit
, based on the specified image.- Parameters:
image
- the image to use for the cursorhotspotX
- the x-coordinate of the cursor's hotspot (the image offset where clicks occur)hotspotY
- the y-coordinate of the cursor's hotspot- Returns:
- a custom cursor as close to the requested form as allowed by the toolkit; if the toolkit does not support custom cursors, the default cursor is returned
-
createCustomCursor
@Deprecated public static java.awt.Cursor createCustomCursor(java.awt.Toolkit toolkit, java.awt.image.BufferedImage image, int hotspotX, int hotspotY, java.lang.String name)
Deprecated.Defines a new custom cursor for use with aToolkit
, based on the specified image.- Parameters:
toolkit
- the toolkit on which to define the cursor (null
for default)image
- the image to use for the cursorhotspotX
- the x-coordinate of the cursor's hotspot (the image offset where clicks occur)hotspotY
- the y-coordinate of the cursor's hotspotname
- the custom cursor name, for accessibility, ornull
to generate a name- Returns:
- a custom cursor as close to the requested form as allowed by the toolkit; if the toolkit does not support custom cursors, the default cursor is returned
-
imageToBufferedImage
public static java.awt.image.BufferedImage imageToBufferedImage(java.awt.Image image)
Returns aBufferedImage
that is equivalent to a specifiedImage
. If the image is already aBufferedImage
, it is returned unmodified. Otherwise, a newBufferedImage
will be created and the contents of the image copied into it. If necessary, the method will wait until the image has finished downloading.- Parameters:
image
- the non-null image to convert- Returns:
- the original image, converted into a
BufferedImage
if it is not already of that type
-
createIconForSize
public static javax.swing.Icon createIconForSize(java.awt.image.BufferedImage image, int size)
Creates an icon fromimage
that is constrained tosize
bysize
pixels.The returned icon is guaranteed to be a
ThemedIcon
.- Parameters:
image
- the image to create an icon fromsize
- the maximum width and height of the icon- Returns:
- an icon created from
image
-
ensureIconHasSize
public static javax.swing.Icon ensureIconHasSize(javax.swing.Icon icon, int size)
Ensures that the supplied icon has the specified size. If the source icon isnull
,null
is returned. Otherwise, if the icon has the correct dimensions it is returned. If not, but the icon is aThemedIcon
, then a new icon is derived from it. Finally, if no other case applies, an image of the icon will be converted into an icon of the requested size.- Parameters:
icon
- the image to create an icon fromsize
- the desired width and height of the icon- Returns:
- an icon of the requested size, or
null
-
iconToImage
public static java.awt.image.BufferedImage iconToImage(javax.swing.Icon i)
Returns the visual content of an icon as an image. If possible, the image will be obtained directly from the icon instance without creating a new image. Note that the size of the image may not match the size of the icon.- Parameters:
i
- the icon- Returns:
- the content of the icon, as an image
-
createDisabledIcon
public static javax.swing.Icon createDisabledIcon(javax.swing.Icon src)
Returns a disabled version of an icon.- Parameters:
src
- the icon to convert- Returns:
- a version of the icon with a suitable "disabled" effect applied
-
createDisabledImage
public static java.awt.image.BufferedImage createDisabledImage(java.awt.image.BufferedImage src)
Returns a disabled version of an image.- Parameters:
src
- the image to convert- Returns:
- a version of the image with a suitable default "disabled" effect applied
-
createGhostedIcon
public static javax.swing.Icon createGhostedIcon(javax.swing.Icon src)
Returns a ghosted version of an icon. Ghosted icons are similar to the original icon, but with every other pixel made transparent in a checkerboard pattern.- Parameters:
src
- the icon to convert- Returns:
- a version of the icon with a ghosting effect applied
-
createDesaturatedIcon
public static javax.swing.Icon createDesaturatedIcon(javax.swing.Icon src)
Returns a greyscale version of an icon.- Parameters:
src
- the icon to convert- Returns:
- a greyscale version of the icon
-
desaturate
public static java.awt.image.BufferedImage desaturate(java.awt.image.BufferedImage src)
Returns a greyscale version of an image.- Parameters:
src
- the image to convert- Returns:
- a greyscale version of the image
- See Also:
GreyscaleFilter
-
invert
public static java.awt.image.BufferedImage invert(java.awt.image.BufferedImage source)
Returns a copy of the source image with the colour values inverted. (Black pixels become white, red pixels become cyan, and so on.)- Parameters:
source
- the image to invert- Returns:
- the inverted image
-
resample
public static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage src, float factor)
Resample an image by a scaling factor, at a high level of quality.- Parameters:
src
- the source imagefactor
- a relative size factor applied to both dimensions- Returns:
- a new image at the requested size
-
resample
public static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage src, float factor, boolean multipass, java.lang.Object finalPassHint, java.lang.Object intermediateHint)
-
resample
public static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage src, int width, int height)
Resample an image to a specified size, at a high level of quality.- Parameters:
src
- the source imagewidth
- the new image widthheight
- the new image height- Returns:
- a new image at the requested size
-
resample
public static java.awt.image.BufferedImage resample(java.awt.image.BufferedImage src, int width, int height, boolean multipass, java.lang.Object finalPassHint, java.lang.Object intermediateHint)
Resample an image. Ifmultipass
istrue
, then the method may split the resampling into multiple passes in order to increase the quality of the result. The quality of the interpolation is also controlled by the hint values, which must be one of theRenderingHints.VALUE_INTERPOLATION_*
values, or elsenull
. (If a hint isnull
, a slow area-averaging algorithm will be used.) The hints determine the type of interpolation used at each stage; the final pass hint is always used exactly once (unless the image is already the requested size). The intermediate hint is used for all other passes, if any. The following table shows some suggested combinations of values, in order from fastest/lowest quality to slowest/highest quality:Suggested resampling combinations multipass finalPassHint intermediateHint false
VALUE_INTERPOLATION_NEAREST_NEIGHBOUR null
(ignored)true
VALUE_INTERPOLATION_BILINEAR VALUE_INTERPOLATION_BILINEAR true
VALUE_INTERPOLATION_BILINEAR VALUE_INTERPOLATION_BICUBIC true
VALUE_INTERPOLATION_BICUBIC VALUE_INTERPOLATION_BICUBIC - Parameters:
src
- the source imagewidth
- the new image widthheight
- the new image heightmultipass
- if multiple passes are allowedfinalPassHint
- a rendering hint specifying the type of interpolation to use for the final passintermediateHint
- a rendering hint specifying the type of interpolation to use for intermediate passes, if any- Returns:
- a new image at the requested size, or the original image if the new size matches the source image
-
idealCoveringScaleForImage
public static double idealCoveringScaleForImage(double idealWidth, double idealHeight, double imageWidth, double imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension. The image will either match the ideal size in the other dimension, or else be larger than the other ideal dimension. If the image is opaque, the result is the scaling factor needed to obtain the smallest image with the same aspect ratio that would completely cover the ideal image area.- Parameters:
idealWidth
- the width of the area the image must coveridealHeight
- the height of the area the image must coverimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that would ensure that the image would just cover the specified area
-
idealCoveringScaleForImage
public static float idealCoveringScaleForImage(float idealWidth, float idealHeight, float imageWidth, float imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension. The image will either match the ideal size in the other dimension, or else be larger than the other ideal dimension. If the image is opaque, the result is the scaling factor to obtain the smallest image with the same aspect ratio that would completely cover the ideal image area.- Parameters:
idealWidth
- the width of the area the image must coveridealHeight
- the height of the area the image must coverimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that would ensure that the image would just cover the specified area
-
idealCoveringScaleForImage
public static float idealCoveringScaleForImage(int idealWidth, int idealHeight, int imageWidth, int imageHeight)
Returns the largest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension. The image will either match the ideal size in the other dimension, or else be larger than the other ideal dimension. If the image is opaque, the result is the scaling factor to obtain the smallest image with the same aspect ratio that would completely cover the ideal image area.- Parameters:
idealWidth
- the width of the area the image must coveridealHeight
- the height of the area the image must coverimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that would ensure that the image would just cover the specified area
-
idealBoundingScaleForImage
public static double idealBoundingScaleForImage(double idealWidth, double idealHeight, double imageWidth, double imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension.- Parameters:
idealWidth
- the width of the area the image must just fit withinidealHeight
- the height of the area the image must just fit withinimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that just fits the image within the bounds, without any of the image lying outside of the ideal area
-
idealBoundingScaleForImage
public static float idealBoundingScaleForImage(float idealWidth, float idealHeight, float imageWidth, float imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension.- Parameters:
idealWidth
- the width of the area the image must just fit withinidealHeight
- the height of the area the image must just fit withinimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that just fits the image within the bounds, without any of the image lying outside of the ideal area
-
idealBoundingScaleForImage
public static float idealBoundingScaleForImage(int idealWidth, int idealHeight, int imageWidth, int imageHeight)
Returns the smallest scaling factor that, when multiplied by the given image size, ensures that the image will match the ideal size in at least one dimension and will not be larger than the ideal size in the other dimension. The result is the largest image that fits within the ideal image dimensions without exceeding them, even though there may be extra space around the image on one dimension.- Parameters:
idealWidth
- the width of the area the image must just fit withinidealHeight
- the height of the area the image must just fit withinimageWidth
- the current width of the image to be fittedimageHeight
- the current height of the image to be fitted- Returns:
- the scale that just fits the image within the bounds, without any of the image lying outside of the ideal area
-
copy
public static java.awt.image.BufferedImage copy(java.awt.image.BufferedImage source)
Returns a copy of the image.- Parameters:
source
- the image to copy- Returns:
- a copy of the image in an integer (A)RGB format
-
center
public static java.awt.image.BufferedImage center(java.awt.image.BufferedImage source, int width, int height)
Returns an image that centres a source image over a new image of a given size.- Parameters:
source
- the source imagewidth
- the width of the new imageheight
- the height of the new image- Returns:
- an integer (A)RGB image containing the source image such that the centre pixels of the two images are aligned
-
pad
public static java.awt.image.BufferedImage pad(java.awt.image.BufferedImage source, int top, int left, int bottom, int right)
Returns an image that is identical to a source image except that it is padded by blank pixels around the outside. The returned image is always of typeTYPE_INT_ARGB
. Margins can be negative, in which case rows or columns are removed from the outside of the image. If the margins are such that the width or height becomes less than 1, a blank 1 by 1 pixel image is returned. If the margin is 0 on all sides and the image type is suitable, the source image is returned.- Parameters:
source
- the source imagetop
- the number of pixels to add to the top edgeleft
- the number of pixels to add to the left edgebottom
- the number of pixels to add to the bottom edgeright
- the number of pixels to add to the right edge- Returns:
- a padded copy of the image
-
trim
public static java.awt.image.BufferedImage trim(java.awt.image.BufferedImage sourceImage)
Create a trimmed version of the source image that excludes fully transparent (alpha=0) rows and columns around the image's edges. If there are no such rows or columns, returns the original image. If the entire image is fully transparent, returns a 1x1 transparent image.- Parameters:
sourceImage
- the image to trim- Returns:
- a trimmed version of the image, or the original image if it does not need trimming
- See Also:
TrimFilter
-
flip
public static java.awt.image.BufferedImage flip(java.awt.image.BufferedImage source, boolean horiz, boolean vert)
Returns a mirrored version of the source image. If neither parameter istrue
, the original image is returned. Otherwise, a copy is returned that is flipped horizontally and/or vertically.- Parameters:
source
- the image to create a mirrored version ofhoriz
- iftrue
, the image is mirrored horizontally (i.e., on the y axis)vert
- iftrue
, the image is mirrored vertically (i.e., on the x axis)- Returns:
- the mirrored version of the image
- See Also:
TurnAndFlipFilter
-
merge
public static java.awt.image.BufferedImage merge(java.awt.image.BufferedImage... images)
Draws a series of images overtop of each other. The images are drawn in the reverse order of the parameters; that is, the first parameter will be drawn overtop of the second, the second over the third and so forth. The images will be drawn directly onto the last image in the list. If this isnull
, a new image will be created with a width and height equal to the maximum width and maximum height of all of the other images. The last image in the last (possibly newly created if it wasnull
) is returned from the method.- Parameters:
images
- a series of images to paint over each other- Returns:
- the bottom image, or a new image if the bottom (last) image was
null
- Throws:
java.lang.NullPointerException
- if anull
array is passed injava.lang.IllegalArgumentException
- if the image array has length 0
-
alphaComposite
public static java.awt.image.BufferedImage alphaComposite(java.awt.image.BufferedImage source, float opacity)
Return a version of this image with an overall transparency change. Pixels with an opacity of 1 (that is, 100%) in the source image will have the specified opacity in the destination image; other pixels with have a new opacity equal to their current opacity times the specified value. For example, if the specified opacity is 0.5, and the source pixel has opacity 0.5, its opacity in the output image will be 0.25.- Parameters:
source
- the original imageopacity
- the alpha level to draw the image at, as a floating point value between 0 and 1- Returns:
- a version of the image at the specified transparency (possibly the original image)
-
isOpaque
public static boolean isOpaque(java.awt.image.BufferedImage bi)
Returnstrue
if every pixel in this image is fully opaque. If the image has no alpha channel, thentrue
is returned immediately. Otherwise, the image is checked pixel-by-pixel.- Parameters:
bi
- the image to check- Returns:
true
if and only if every pixel is opaque- Throws:
java.lang.NullPointerException
- if the image isnull
-
waitForImage
public static java.awt.Image waitForImage(java.awt.Image im)
Waits for an image to load. GenericImage
instances, such as those obtained from theToolkit
are designed to load in the background. As a result, certain methods may return wrong or temporary values. This method ensures that a target image is fully loaded (or failed to load) before returning. Note thatBufferedImage
s never load in the background. If passed aBufferedImage
this method returns immediately.- Parameters:
im
- the image to wait for- Returns:
- the image that was passed in
-
-