public class StampOp extends AbstractBufferedImageOp
StampOp
is an image operation, which may scale the source
image to the destination image and put a stamp mark ontop of the (scaled)
destination image. The location and size as well as the mark it self must be
provided to the operation before the filter
method is called.
The operation can be reused to stamp multiple images.
Sample use:
// create op with no rendering hints StampOp op = new StampOp(); // set the stamp image op.setStamp(watermarkImage); // set the top,left location, default is (0, 0) op.setStampLocation(20, 20); // set the stamp size, default is (15, 15) op.setStampSize(30, 30); // draw stamp with 50% opacity (default is 100% opacity) op.setStampComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f)); // apply the stamp stampedImage = op.filter(rawImage, null);
Constructor and Description |
---|
StampOp()
Creates an instance of this operation with no rendering hints.
|
StampOp(java.awt.RenderingHints hints)
Creates an instance of this operation with the given rendering hints.
|
Modifier and Type | Method and Description |
---|---|
java.awt.image.BufferedImage |
filter(java.awt.image.BufferedImage src,
java.awt.image.BufferedImage dst)
Applies the stamp on the source image.
|
java.awt.image.BufferedImage |
getStamp()
Returns the stamp image or
null if it has not yet been set. |
java.awt.Composite |
getStampComposite()
Returns the current composite used to draw the image.
|
java.awt.geom.Rectangle2D |
getStampPosition()
Returns the stamp location and size as a rectangle whose x and y fields
define the top,left position and the width and height of the rectangle
define the width and height of the stamp.
|
void |
setStamp(java.awt.image.BufferedImage stamp)
Sets the stamp image.
|
void |
setStampComposite(java.awt.Composite stampComposite)
Sets the
Composite used to draw the stamp on the image. |
void |
setStampLocation(int x,
int y)
Sets the top, left location of the stamp.
|
void |
setStampSize(int width,
int height)
Sets the width and height of the stamp to be drawn.
|
createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
public StampOp(java.awt.RenderingHints hints)
hints
- The rendering hints to apply for the filter operation. This
may be null
.public StampOp()
public void setStamp(java.awt.image.BufferedImage stamp)
null
, the operation does
nothing else than copying the source image into the destination image.public java.awt.image.BufferedImage getStamp()
null
if it has not yet been set.public void setStampLocation(int x, int y)
public void setStampSize(int width, int height)
public java.awt.geom.Rectangle2D getStampPosition()
public void setStampComposite(java.awt.Composite stampComposite)
Composite
used to draw the stamp on the image. The
default value is AlphaComposite.Src
which draws the stamp
with full opacity.stampComposite
- The Composite
. If this is
null
the current composite is not replaced.public java.awt.Composite getStampComposite()
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
null
a new image with the
same size and color setup as the source image is created to draw the
source image and stamp.filter
in interface java.awt.image.BufferedImageOp
filter
in class AbstractBufferedImageOp
src
- The src image to be operated upon.dst
- The dest image into which to place the modified image. This
may be null
in which case a new image with the
correct size will be created.null
) or dest
into which the resized src image has been drawn."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"