Package org.xhtmlrenderer.util
Class ScalingOptions
java.lang.Object
org.xhtmlrenderer.util.ScalingOptions
Encapsulates a set of parameters related to scaling quality and output. Values are final once constructed, except
for target width and height, which can be change and the options instance reused.
There is a default constructor for average quality and performance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DownscaleQuality
private final Object
private final int
private final int
-
Constructor Summary
ConstructorsConstructorDescriptionScalingOptions
(int targetWidth, int targetHeight, DownscaleQuality downscalingHint, Object hint) Constructor with all options. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies any rendering hints configured for these ScalingOptions to a Graphics2D instance before image operations are called on it.protected Map<RenderingHints.Key,
Object> Returns a Map of image rendering hints applicable toGraphics2D.setRenderingHints(java.util.Map)
.int
int
boolean
sizeMatches
(int w, int h) Returns true if the target size specified by these options matches the size provided (e.g.withTarget
(int targetWidth, int targetHeight)
-
Field Details
-
downscalingHint
-
renderingHint
-
targetWidth
private final int targetWidth -
targetHeight
private final int targetHeight
-
-
Constructor Details
-
ScalingOptions
public ScalingOptions(int targetWidth, int targetHeight, DownscaleQuality downscalingHint, Object hint) Constructor with all options.- Parameters:
targetWidth
- Target width in pixels of image once scaledtargetHeight
- Target height in pixels of image once scaleddownscalingHint
- Directs downscaling quality. One of the enumerated types ofDownscaleQuality
such asDownscaleQuality.FAST
.hint
- Hint for interpolation to AWT image renderer, one of the Object constants fromRenderingHints
usingRenderingHints.KEY_INTERPOLATION
-
-
Method Details
-
getDownscalingHint
-
getRenderingHint
-
applyRenderingHints
Applies any rendering hints configured for these ScalingOptions to a Graphics2D instance before image operations are called on it. These might be- Parameters:
g2
- A Graphics2D instance on which scaled images will be rendered.
-
getRenderingHints
Returns a Map of image rendering hints applicable toGraphics2D.setRenderingHints(java.util.Map)
. By default, this will only include the interpolation hint specified for this ScalingOptions. Other hints could be added in an overridden version in a subclass.- Returns:
- Map of rendering hints.
-
sizeMatches
public boolean sizeMatches(int w, int h) Returns true if the target size specified by these options matches the size provided (e.g. image is already at target size).- Parameters:
w
- an image widthh
- an image height- Returns:
- true if image dimensions already match target size
-
getTargetWidth
public int getTargetWidth() -
getTargetHeight
public int getTargetHeight() -
withTarget
-