Package org.apache.pdfbox.jbig2.image
Class Resizer
java.lang.Object
org.apache.pdfbox.jbig2.image.Resizer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
private static enum
Order in which to apply filter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
Number of bits per channelprivate final boolean
Should filters be simplified if possible?(package private) static final boolean
private static final double
Error toleranceprivate int[]
private final Resizer.Mapping
private final Resizer.Mapping
private static final int[]
private final Resizer.Order
The order in which data is processed.private final boolean
Should zeros be trimmed in x filter weight tables?private int
Number of bits in filter coefficientsprivate int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Scanline
createScanline
(Object src, Object dst, int length) private Weighttab[]
createXWeights
(Rectangle srcBounds, Rectangle dstBounds, ParameterizedFilter filter) private static boolean
isInteger
(double x) Is x an integer?void
resize
(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, Filter xFilter, Filter yFilter) private void
resizeXfirst
(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, ParameterizedFilter xFilter, ParameterizedFilter yFilter) Filtered zoom, x direction filtering before y direction filteringprivate void
resizeYfirst
(Object src, Rectangle srcBounds, Object dst, Rectangle dstBounds, ParameterizedFilter xFilter, ParameterizedFilter yFilter) Filtered zoom, y direction filtering before x direction filteringprivate 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.
-
Field Details
-
EPSILON
private static final double EPSILONError tolerance- See Also:
-
weightBits
private int weightBitsNumber of bits in filter coefficients -
weightOne
private int weightOne -
bitsPerChannel
private int[] bitsPerChannelNumber 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 coerceShould filters be simplified if possible?- See Also:
-
order
The order in which data is processed.- See Also:
-
trimZeros
private final boolean trimZerosShould zeros be trimmed in x filter weight tables?- See Also:
-
mappingX
-
mappingY
-
-
Constructor Details
-
Resizer
public Resizer(double scale) Creates an instance ofResizer
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 ofResizer
with a scale factor for each direction.- Parameters:
scaleX
- the scale factor for x directionscaleY
- 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
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 simplifiedscale
- the scale of the coordinate mappingoffset
- 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 filteringNote: 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 objectsrcBounds
- Bounds of the source objectdst
- Destination objectdstBounds
- Bounds of the destination objectxFilter
- The filter used for x direction filteringyFilter
- The filter used for y direction filtering
-
createScanline
-