One way to use an image resource creation scripts is to break a large image into smaller ones in such a way that they can be stored more efficiently. This reduces the download footprint of the program. A good example is an image that is mostly opaque with a small transparent area. Transparent images are not stored as efficiently as non-transparent ones, so it may be more efficient to split the image into two or more pieces and store each in a separate file. The pieces are then combined into the final image at runtime by the resource creation script.
ImageUtils.STITCH_HORIZONTAL | indicates that images should be stitched from left to right |
ImageUtils.STITCH_VERTICAL | indicates that images should be stitched from top to bottom |
width | the image width, in pixels |
height | the image height, in pixels |
hasTransparency | if true, create an alpha channel for the image (default is false) |
returns a BufferedImage with the requested parameters
dpi | the image resolution, in dots (pixels) per inch |
width | the image width, in points |
height | the image height, in points |
hasTransparency | if true, create an alpha channel for the image (default is false) |
returns a BufferedImage with the requested parameters
relativeURL | a URL string relative to the resources folder |
cacheResult | if true, the image may be cached to speed future requests (default is true) |
quietly | if true, no error message is displayed if loading fails (default is false, i.e., display a message) |
returns the image resource as a BufferedImage, or null
relativeURL | a URL string relative to the resources folder |
unthemed | if true, then the current theme will not be allowed to substitute a different image (default is false) |
returns the image resource as a javax.swing.ImageIcon, or null
image | the image to use in the icon |
size | the target size for the icon (default is 16) |
returns an icon that displays the image and is the requested size
returns a copy of the source image
image1 | the first BufferedImage to be stitched |
image2 | the second BufferedImage to be stitched |
stitchEdge | a constant indicating which edges to join |
returns a BufferedImage that joins the source images at their edges
image | the image to create a resized copy of |
width | the width of the new image, in pixels |
height | the height of the new image, in pixels |
fast | an optional hint; if true, lower quality but faster resampling is performed (default is false) |
returns a resized copy of image
image | the image to fit within the space |
width | the maximum width of the resized image |
height | the maximum height of the resized image |
fast | if true a faster but lower quality algorithm is used (default is false) |
image | the source image, which is not changed |
x | the x-coordinate of the upper-left corner of the region to retain in the destination |
y | the y-coordinate of the upper-left corner of the region to retain in the destination |
width | the width of the region to retain in the destination |
height | the height of the region to retain in the destination |
image | a BufferedImage to pad |
top | the number of pixels to add to the top edge |
left | the number of pixels to add to the left edge |
bottom | the number of pixels to add to the bottom edge |
right | the number of pixels to add to the right edge |
returns a padded copy of image
image | the image to tint |
h | the hue shift to apply |
s | the saturation factor to apply |
b | the brightness factor to apply |
returns a tinted copy of image
image | a BufferedImage to mirror |
horiz | if true, flip horizontally (default is true) |
vert | if true, flip vertically (default is false) |
returns a mirrored copy of image
image | the image to invert |
returns the inverse image
image | the image to desaturate |
returns the desaturated image
file | the name of the file to read |
returns the image, or throws an error if reading fails
image | the image to write |
file | the file to write to; either a file name string or a File object |
format | a string describing the format to write the image in (default is "png") |
quality | a value between 0 and 1 (inclusive) to control compression quality (higher is better quality, -1 for default) |
progressive | if true requests an image that can be displayed progressively as it downloads (default is false) |
ppi | if supported by the image encoder, the image's metadata will indicate that this is the resolution of the image (in pixels per inch) |
ImageUtils.FORMAT_PNG | the PNG (png) image format |
ImageUtils.FORMAT_JPEG | the JPEG (jpg) image format |
ImageUtils.FORMAT_JPEG2000 | the JPEG2000 (jp2) image format |
ImageUtils.FORMAT_BMP | the BMP (bmp) image format |
ImageUtils.FORMAT_GIF | the GIF89a (gif) image format |
Prompts the user to choose a file, then saves image to the selected file. If no defaultFile is specified, then a default location is selected based on the last saved file, or if no image file has been saved previously, a platform-specific default location is used. The value of defaultFile may either be a java.io.File object, or else it can be another object whose string representation is a valid path on this platform.
image | the image to be written |
defaultFile | an optional default location to save to |
parent | an optional parent for the file chooser; defaults to the main application window |
returns the java.io.File that was saved, or null if the user cancelled the save operation
image | a BufferedImage to display |
title | an optional title for the view window |
modal | if true, the viewer should be modal (blocks the application until closed) |
parent | an optional parent for the file chooser; defaults to the main application window |