Class Resizer

java.lang.Object
org.apache.pdfbox.jbig2.image.Resizer

class Resizer extends Object
  • Field Details

    • EPSILON

      private static final double EPSILON
      Error tolerance
      See Also:
    • weightBits

      private int weightBits
      Number of bits in filter coefficients
    • weightOne

      private int weightOne
    • bitsPerChannel

      private int[] bitsPerChannel
      Number of bits per channel
    • NO_SHIFT

      private static final int[] NO_SHIFT
    • finalShift

      private int[] finalShift
    • debug

      static final boolean debug
      See Also:
    • coerce

      private final boolean coerce
      Should filters be simplified if possible?
      See Also:
    • order

      private final Resizer.Order order
      The order in which data is processed.
      See Also:
    • trimZeros

      private final boolean trimZeros
      Should zeros be trimmed in x filter weight tables?
      See Also:
    • mappingX

      private final Resizer.Mapping mappingX
    • mappingY

      private final Resizer.Mapping mappingY
  • Constructor Details

    • Resizer

      public Resizer(double scale)
      Creates an instance of Resizer with one scale factor for both x and y directions.
      Parameters:
      scale - the scale factor for x and y direction
    • Resizer

      public Resizer(double scaleX, double scaleY)
      Creates an instance of Resizer with a scale factor for each direction.
      Parameters:
      scaleX - the scale factor for x direction
      scaleY - the scale factor for y direction
  • Method Details

    • isInteger

      private static boolean isInteger(double x)
      Is x an integer?
      Parameters:
      x - the double to check
      Returns:
      true if x is an integer, false if not.
    • createXWeights

      private Weighttab[] createXWeights(Rectangle srcBounds, Rectangle dstBounds, ParameterizedFilter filter)
    • simplifyFilter

      private ParameterizedFilter simplifyFilter(ParameterizedFilter filter, double scale, double offset)
      Checks if our discrete sampling of an arbitrary continuous filter, parameterized by the filter spacing (ParameterizedFilter.scale), its radius (ParameterizedFilter.support), and the scale and offset of the coordinate mapping, causes the filter to reduce to point sampling.

      It reduces if support is less than 1 pixel or if integer scale and translation, and filter is cardinal.

      Parameters:
      filter - the parameterized filter instance to be simplified
      scale - the scale of the coordinate mapping
      offset - the offset of the coordinate mapping
    • resizeXfirst

      private void resizeXfirst(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, ParameterizedFilter xFilter, ParameterizedFilter yFilter)
      Filtered zoom, x direction filtering before y direction filtering

      Note: when calling createXWeights(Rectangle, Rectangle, ParameterizedFilter), we can trim leading and trailing zeros from the x weight buffers as an optimization, but not for y weight buffers since the split formula is anticipating a constant amount of buffering of source scanlines; trimming zeros in y weight could cause feedback.

    • resizeYfirst

      private void resizeYfirst(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, ParameterizedFilter xFilter, ParameterizedFilter yFilter)
      Filtered zoom, y direction filtering before x direction filtering
    • resize

      public void resize(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, Filter xFilter, Filter yFilter)
      Parameters:
      src - Source object
      srcBounds - Bounds of the source object
      dst - Destination object
      dstBounds - Bounds of the destination object
      xFilter - The filter used for x direction filtering
      yFilter - The filter used for y direction filtering
    • createScanline

      private static Scanline createScanline(Object src, Object dst, int length)