Class Transparency
- java.lang.Object
-
- net.coobird.thumbnailator.filters.Transparency
-
- All Implemented Interfaces:
ImageFilter
public class Transparency extends java.lang.Object implements ImageFilter
An image filter which will make an image transparent.The resulting image will always have an image type of
BufferedImage.TYPE_INT_ARGB.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.AlphaCompositecompositeThe alpha composite to use when drawing the transparent image.
-
Constructor Summary
Constructors Constructor Description Transparency(double alpha)Instantiates aTransparencyfilter with the specified opacity.Transparency(float alpha)Instantiates aTransparencyfilter with the specified opacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImageapply(java.awt.image.BufferedImage img)Applies a image filtering operation on an image.floatgetAlpha()Returns the opacity of this filter.
-
-
-
Constructor Detail
-
Transparency
public Transparency(float alpha)
Instantiates aTransparencyfilter with the specified opacity.- Parameters:
alpha- The opacity of the resulting image. The value should be between0.0f(transparent) to1.0f(opaque), inclusive.- Throws:
java.lang.IllegalArgumentException- If the specified opacity is outside of the range specified above.
-
Transparency
public Transparency(double alpha)
Instantiates aTransparencyfilter with the specified opacity.This is a convenience constructor for the
Transparency(float)constructor.- Parameters:
alpha- The opacity of the resulting image. The value should be between0.0f(transparent) to1.0f(opaque), inclusive.- Throws:
java.lang.IllegalArgumentException- If the specified opacity is outside of the range specified above.
-
-
Method Detail
-
apply
public java.awt.image.BufferedImage apply(java.awt.image.BufferedImage img)
Description copied from interface:ImageFilterApplies a image filtering operation on an image.- Specified by:
applyin interfaceImageFilter- Parameters:
img- The image to apply the filtering on.- Returns:
- The resulting image after applying this filter.
-
getAlpha
public float getAlpha()
Returns the opacity of this filter.- Returns:
- The opacity in the range of
0.0f(transparent) to1.0f(opaque).
-
-