Class ScalingOptions

java.lang.Object
org.xhtmlrenderer.util.ScalingOptions

public class ScalingOptions extends Object
POJO used when calling ImageUtil.getScaledInstance(ScalingOptions, BufferedImage). 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 Details

    • downscalingHint

      private final DownscaleQuality downscalingHint
    • renderingHint

      private final Object renderingHint
    • targetWidth

      private int targetWidth
    • targetHeight

      private int targetHeight
  • Constructor Details

  • Method Details

    • getDownscalingHint

      public DownscaleQuality getDownscalingHint()
    • getRenderingHint

      public Object getRenderingHint()
    • applyRenderingHints

      public void applyRenderingHints(Graphics2D g2)
      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

      protected Map<RenderingHints.Key,Object> getRenderingHints()
      Returns a Map of image rendering hints applicable to Graphics2D.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 width
      h - an image height
      Returns:
      true if image dimensions already match target size
    • sizeMatches

      public boolean sizeMatches(Image img)
      Returns true if the target size specified by these options matches the size provided (e.g. image is already at target size).
      Returns:
      true if image dimensions already match target size
    • getTargetWidth

      public int getTargetWidth()
    • getTargetHeight

      public int getTargetHeight()
    • setTargetWidth

      public void setTargetWidth(int targetWidth)
    • setTargetHeight

      public void setTargetHeight(int targetHeight)
    • setTargetDimensions

      public void setTargetDimensions(Dimension dim)