Package generic.util.image
Class ImageUtils
java.lang.Object
generic.util.image.ImageUtils
- 
Method SummaryModifier and TypeMethodDescriptionstatic ImagechangeColor(Image image, Color oldColor, Color newColor) Creates a new image that is the same as the given image but has the given colored pixels replaced with the given new colorstatic ImagecreateDisabledImage(Image image, int brightnessPercent) Creates a disabled version of the given image.static BufferedImagecreateEmptyImage(int width, int height) Creates a new image of the given size.static ImageCreates an image of the given componentstatic ImagecreateScaledImage(Image image, int width, int height, int hints) Creates a scaled image based upon the given image.static ImageCrops the given image, keeping the given boundsstatic BufferedImagegetBufferedImage(Image image) Copies this image into a buffered image.static IconmakeTransparent(Icon icon) Make the specified icon semi-transparent using the default transparency alphastatic IconmakeTransparent(Icon icon, float alpha) Make the specified icon semi-transparent using the specified transparency alphastatic ImagePads the given image with space in the amount given.static ImageplaceImagesSideBySide(Image left, Image right) Places the two given images side-by-side into a new image.static BufferedImageLoad an image from a filestatic RenderedImagetoRenderedImage(Image image) Turns the given image into aRenderedImagestatic booleanwaitForImage(String imageName, Image image) Waits a reasonable amount of time for the given image to loadstatic voidwriteFile(RenderedImage i, File imageFile) Write the specified image to file in PNG formatstatic voidWrite the specified image to file in PNG formatstatic voidwriteIconToPNG(Icon icon, String filename) Writes the given icon out to the file denoted byfilenamein the PNG format.
- 
Method Details- 
createImageCreates an image of the given component- Parameters:
- c- the component
- Returns:
- the image
 
- 
padImagePads the given image with space in the amount given.- Parameters:
- i- the image to pad
- c- the color to use for the padding background
- top- the top padding
- left- the left padding
- right- the right padding
- bottom- the bottom padding
- Returns:
- a new image with the given image centered inside of padding
 
- 
cropCrops the given image, keeping the given bounds- Parameters:
- i- the image to crop
- bounds- the new bounds
- Returns:
- a new image based on the given image, cropped to the given bounds.
 
- 
createEmptyImageCreates a new image of the given size. This image is suitable for drawing operations.- Parameters:
- width- the width of the new image
- height- the height of the new image
- Returns:
- a new image of the given size. This image is suitable for drawing operations.
 
- 
placeImagesSideBySidePlaces the two given images side-by-side into a new image.- Parameters:
- left- the left image
- right- the right image
- Returns:
- a new image with the two given images side-by-side into a new image.
 
- 
toRenderedImageTurns the given image into aRenderedImage- Parameters:
- image- the image
- Returns:
- the rendered image
 
- 
getBufferedImageCopies this image into a buffered image. If this image is already a buffered image, then it will be returned.- Parameters:
- image- the image
- Returns:
- the buffered image
 
- 
waitForImageWaits a reasonable amount of time for the given image to load- Parameters:
- imageName- the name of the image
- image- the image for which to wait
- Returns:
- true if the wait was successful
 
- 
writeFileWrite the specified image to file in PNG format- Parameters:
- i- the image to save
- imageFile- the file to save the image to
- Throws:
- IOException- if there is an exception
 
- 
writeFileWrite the specified image to file in PNG format- Parameters:
- i- the image to save
- imageFile- the file to save the image to
- Throws:
- IOException- if there is an exception
 
- 
readFileLoad an image from a file- Parameters:
- imageFile- image source-data file
- Returns:
- the image, decoded from bytes in specified file
- Throws:
- IOException- if there is an exception
 
- 
writeIconToPNGWrites the given icon out to the file denoted byfilenamein the PNG format.- Parameters:
- icon- the icon to write
- filename- the filename denoting the write destination
- Throws:
- IOException- see- ImageIO.write(RenderedImage, String, File)
 
- 
makeTransparentMake the specified icon semi-transparent using the default transparency alpha- Parameters:
- icon- The icon to make semi-transparent
- Returns:
- a new icon, based on the original, made semi-transparent
- See Also:
 
- 
makeTransparentMake the specified icon semi-transparent using the specified transparency alpha- Parameters:
- icon- the icon to make semi-transparent
- alpha- the alpha value to use in making the icon transparent
- Returns:
- a new icon, based on the original, made semi-transparent
 
- 
createScaledImageCreates a scaled image based upon the given image. NOTE: Avoid invocation by a static initializer.- Parameters:
- image- the image to scale
- width- the new width
- height- the new height
- hints-- RenderingHintsused by- Graphics2D
- Returns:
- a scaled version of the given image
 
- 
createDisabledImageCreates a disabled version of the given image. The disabled version will be grayed and have the varying gray levels blended together.- Parameters:
- image- the image to disable
- brightnessPercent- the amount of brightness to apply; 0-100
- Returns:
- the new image
 
- 
changeColorCreates a new image that is the same as the given image but has the given colored pixels replaced with the given new color- Parameters:
- image- the image to change
- oldColor- the color to replace
- newColor- the color to use
- Returns:
- the new image
 
 
-