Class AbstractResizer
- java.lang.Object
-
- net.coobird.thumbnailator.resizers.AbstractResizer
-
- All Implemented Interfaces:
Resizer
- Direct Known Subclasses:
BicubicResizer,BilinearResizer,NullResizer,ProgressiveBilinearResizer
public abstract class AbstractResizer extends java.lang.Object implements Resizer
A class which performs a resize operation on a source image and outputs the result to a destination image.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.awt.RenderingHints.KeyKEY_INTERPOLATIONprotected java.util.Map<java.awt.RenderingHints.Key,java.lang.Object>RENDERING_HINTSRendering hints to use when resizing an image.protected java.util.Map<java.awt.RenderingHints.Key,java.lang.Object>UNMODIFIABLE_RENDERING_HINTSField used to hold the rendering hints in an unmodifiable form.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractResizer(java.lang.Object interpolationValue, java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> hints)Initializes theAbstractResizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Graphics2DcreateGraphics(java.awt.image.BufferedImage img)Returns aGraphics2Dobject with rendering hints pre-applied.java.util.Map<java.awt.RenderingHints.Key,java.lang.Object>getRenderingHints()Returns the rendering hints that the resizer uses.protected voidperformChecks(java.awt.image.BufferedImage srcImage, java.awt.image.BufferedImage destImage)Performs checks on the source and destination image to see if they are images which can be processed.voidresize(java.awt.image.BufferedImage srcImage, java.awt.image.BufferedImage destImage)Performs a resize operation from a source image and outputs to a destination image.
-
-
-
Field Detail
-
RENDERING_HINTS
protected final java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> RENDERING_HINTS
Rendering hints to use when resizing an image.
-
UNMODIFIABLE_RENDERING_HINTS
protected final java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> UNMODIFIABLE_RENDERING_HINTS
Field used to hold the rendering hints in an unmodifiable form.
-
KEY_INTERPOLATION
protected static final java.awt.RenderingHints.Key KEY_INTERPOLATION
-
-
Constructor Detail
-
AbstractResizer
protected AbstractResizer(java.lang.Object interpolationValue, java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> hints)Initializes theAbstractResizer.- Parameters:
interpolationValue- The rendering hint value to use for the interpolation hint.hints- Other rendering hints to add.
-
-
Method Detail
-
resize
public void resize(java.awt.image.BufferedImage srcImage, java.awt.image.BufferedImage destImage)Performs a resize operation from a source image and outputs to a destination image.
If the source or destination image is
null, then aNullPointerExceptionwill be thrown.
-
createGraphics
protected java.awt.Graphics2D createGraphics(java.awt.image.BufferedImage img)
Returns aGraphics2Dobject with rendering hints pre-applied.- Parameters:
img-BufferedImagefor which theGraphics2Dobject should be generated for.- Returns:
Graphics2Dobject for the givenBufferedImage.
-
performChecks
protected void performChecks(java.awt.image.BufferedImage srcImage, java.awt.image.BufferedImage destImage)Performs checks on the source and destination image to see if they are images which can be processed.- Parameters:
srcImage- The source image.destImage- The destination image.
-
getRenderingHints
public java.util.Map<java.awt.RenderingHints.Key,java.lang.Object> getRenderingHints()
Returns the rendering hints that the resizer uses.The keys and values used for the rendering hints are those defined in the
RenderingHintsclass.- Returns:
- Rendering hints used when resizing the image.
- See Also:
RenderingHints
-
-