Package com.twelvemonkeys.imageio.path
Class Paths
- java.lang.Object
-
- com.twelvemonkeys.imageio.path.Paths
-
public final class Paths extends java.lang.Object
Support for various Adobe Photoshop Path related operations:- Extract a path from an image input stream,
readPath(javax.imageio.stream.ImageInputStream)
- Apply a given path to a given
BufferedImage
applyClippingPath(java.awt.Shape, java.awt.image.BufferedImage)
- Read an image with path applied
readClipped(javax.imageio.stream.ImageInputStream)
- Version:
- $Id: Paths.java,v 1.0 08/12/14 harald.kuhr Exp$
- Author:
- Jason Palmer, itemMaster LLC, Harald Kuhr, last modified by $Author: harald.kuhr$
- See Also:
- Adobe Photoshop Path resource format,
AdobePathBuilder
- Extract a path from an image input stream,
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.image.BufferedImage
applyClippingPath(java.awt.Shape clip, java.awt.image.BufferedImage image)
Applies the clipping path to the given image.static java.awt.image.BufferedImage
applyClippingPath(java.awt.Shape clip, java.awt.image.BufferedImage image, java.awt.image.BufferedImage destination)
Applies the clipping path to the given image.static void
main(java.lang.String[] args)
static java.awt.image.BufferedImage
readClipped(javax.imageio.stream.ImageInputStream stream)
Reads the clipping path from the given input stream, if any, and applies it to the first image in the stream.static java.awt.geom.Path2D
readPath(javax.imageio.stream.ImageInputStream stream)
Reads the clipping path from the given input stream, if any.
-
-
-
Method Detail
-
readPath
public static java.awt.geom.Path2D readPath(javax.imageio.stream.ImageInputStream stream) throws java.io.IOException
Reads the clipping path from the given input stream, if any. Supports PSD, JPEG and TIFF as container formats for Photoshop resources, or a "bare" PSD Image Resource Block.- Parameters:
stream
- the input stream to read from, notnull
.- Returns:
- the path, or
null
if no path is found - Throws:
java.io.IOException
- if a general I/O exception occurs during reading.javax.imageio.IIOException
- if the input contains a bad path data.java.lang.IllegalArgumentException
- isstream
isnull
.- See Also:
AdobePathBuilder
-
applyClippingPath
public static java.awt.image.BufferedImage applyClippingPath(java.awt.Shape clip, java.awt.image.BufferedImage image)
Applies the clipping path to the given image. All pixels outside the path will be transparent.- Parameters:
clip
- the clipping path, notnull
image
- the image to clip, notnull
- Returns:
- the clipped image.
- Throws:
java.lang.IllegalArgumentException
- ifclip
orimage
isnull
.
-
applyClippingPath
public static java.awt.image.BufferedImage applyClippingPath(java.awt.Shape clip, java.awt.image.BufferedImage image, java.awt.image.BufferedImage destination)
Applies the clipping path to the given image. Client code may decide the type of thedestination
image. Thedestination
image is assumed to be fully transparent, and have same dimensions asimage
. All pixels outside the path will be transparent.- Parameters:
clip
- the clipping path, notnull
.image
- the image to clip, notnull
.destination
- the destination image, may not benull
or same instance asimage
.- Returns:
- the clipped image.
- Throws:
java.lang.IllegalArgumentException
- ifclip
,image
ordestination
isnull
, or ifdestination
is the same instance asimage
.
-
readClipped
public static java.awt.image.BufferedImage readClipped(javax.imageio.stream.ImageInputStream stream) throws java.io.IOException
Reads the clipping path from the given input stream, if any, and applies it to the first image in the stream. If no path was found, the image is returned without any clipping. Supports PSD, JPEG and TIFF as container formats for Photoshop resources.- Parameters:
stream
- the stream to read from, notnull
- Returns:
- the clipped image
- Throws:
java.io.IOException
- if a general I/O exception occurs during reading.javax.imageio.IIOException
- if the input contains a bad image or path data.java.lang.IllegalArgumentException
- isstream
isnull
.
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.InterruptedException
- Throws:
java.io.IOException
java.lang.InterruptedException
-
-