public final class Paths extends Object
readPath(javax.imageio.stream.ImageInputStream)BufferedImage applyClippingPath(java.awt.Shape, java.awt.image.BufferedImage)readClipped(javax.imageio.stream.ImageInputStream)writeClipped(java.awt.image.RenderedImage, java.awt.Shape, java.lang.String, javax.imageio.stream.ImageOutputStream)AdobePathReader| Modifier and Type | Method and Description |
|---|---|
static BufferedImage |
applyClippingPath(Shape clip,
BufferedImage image)
Applies the clipping path to the given image.
|
static BufferedImage |
applyClippingPath(Shape clip,
BufferedImage image,
BufferedImage destination)
Applies the clipping path to the given image.
|
static void |
main(String[] args) |
static BufferedImage |
readClipped(ImageInputStream stream)
Reads the clipping path from the given input stream, if any,
and applies it to the first image in the stream.
|
static Path2D |
readPath(ImageInputStream stream)
Reads the clipping path from the given input stream, if any.
|
static boolean |
writeClipped(RenderedImage image,
Shape clipPath,
String formatName,
ImageOutputStream output)
Writes the image along with a clipping path resource, in the given format, to the supplied output.
|
public static Path2D readPath(ImageInputStream stream) throws IOException
stream - the input stream to read from, not null.null if no path is foundIOException - if a general I/O exception occurs during reading.IIOException - if the input contains a bad path data.IllegalArgumentException - is stream is null.AdobePathReaderpublic static BufferedImage applyClippingPath(Shape clip, BufferedImage image)
clip - the clipping path, not nullimage - the image to clip, not nullIllegalArgumentException - if clip or image is null.public static BufferedImage applyClippingPath(Shape clip, BufferedImage image, BufferedImage destination)
destination image.
The destination image is assumed to be fully transparent,
and have same dimensions as image.
All pixels outside the path will be transparent.clip - the clipping path, not null.image - the image to clip, not null.destination - the destination image, may not be null or same instance as image.IllegalArgumentException - if clip, image or destination is null,
or if destination is the same instance as image.public static BufferedImage readClipped(ImageInputStream stream) throws IOException
stream - the stream to read from, not nullIOException - if a general I/O exception occurs during reading.IIOException - if the input contains a bad image or path data.IllegalArgumentException - is stream is null.public static boolean writeClipped(RenderedImage image, Shape clipPath, String formatName, ImageOutputStream output) throws IOException
ImageOutputStream starting at the current stream
pointer, overwriting existing stream data from that point
forward, if present.
Note: As ImageIO.write(RenderedImage, String, ImageOutputStream), this method does
not close the output stream.
It is the responsibility of the caller to close the stream, if desired.
Implementation note: Only JPEG (using the "javax_imageio_jpeg_image_1.0" metadata format) and TIFF (using the "javax_imageio_tiff_image_1.0" or "com_sun_media_imageio_plugins_tiff_image_1.0" metadata formats) formats are currently supported.
image - the image to be written, may not be null.clipPath - the clip path, may not be null.formatName - the informal format name, may not be null.output - the stream to write to, may not be null.true if the image was written,
otherwise false (ie. no writer was found for the specified format).IllegalArgumentException - if any parameter is null.IOException - if an error occurs during writing.public static void main(String[] args) throws IOException, InterruptedException
IOExceptionInterruptedExceptionCopyright © 2023. All rights reserved.