Top Fields Constructors Methods
org.apache.poi.ss.util

public final Class ImageUtils

extends Object
Class Inheritance
Static Imports
org.apache.poi.util.Units.EMU_PER_PIXEL

Field Summary

Modifier and TypeField and Description
private static final int
private static final Logger
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Dimension

Returns:

the dimensions in EMUs
getDimensionFromAnchor
(Picture
the picture containing the anchor
picture
)

Calculates the dimensions in EMUs for the anchor of the given picture

private static int
getDimFromCell(double imgSize, int startCell, int startD, int endCell, int endD, int hssfUnits, Function<Integer, Number> nextSize)

public static Dimension

Returns:

image dimension in pixels
getImageDimension
(InputStream
the stream containing the image data
is
,
int type)

Return the dimension of this image

public static int[]

Returns:

array of two elements: {horizontalDpi, verticalDpi}. {96, 96} is the default.
getResolution
(ImageReader r)

The metadata of PNG and JPEG can contain the width of a pixel in millimeters.

public static double
getRowHeightInPixels(Sheet sheet, int rowNum)

private static void
scaleCell(final double targetSize, final int startCell, final int startD, Consumer<Integer> endCell, Consumer<Integer> endD, final int hssfUnits, Function<Integer, Number> nextSize)

public static Dimension

Returns:

the new Dimensions of the scaled picture in EMUs
setPreferredSize
(Picture picture, double
the amount by which image width is multiplied relative to the original width.
scaleX
,
double
the amount by which image height is multiplied relative to the original height.
scaleY
)

Calculate and set the preferred size (anchor) for this picture.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEIGHT_UNITSback to summary
private static final int HEIGHT_UNITS
LOGback to summary
private static final Logger LOG
WIDTH_UNITSback to summary
private static final int WIDTH_UNITS

Constructor Detail

ImageUtilsback to summary
private ImageUtils()

Method Detail

getDimensionFromAnchorback to summary
public static Dimension getDimensionFromAnchor(Picture picture)

Calculates the dimensions in EMUs for the anchor of the given picture

Parameters
picture:Picture

the picture containing the anchor

Returns:Dimension

the dimensions in EMUs

getDimFromCellback to summary
private static int getDimFromCell(double imgSize, int startCell, int startD, int endCell, int endD, int hssfUnits, Function<Integer, Number> nextSize)
getImageDimensionback to summary
public static Dimension getImageDimension(InputStream is, int type)

Return the dimension of this image

Parameters
is:InputStream

the stream containing the image data

type:int

type of the picture: Workbook#PICTURE_TYPE_JPEG, Workbook#PICTURE_TYPE_PNG or Workbook#PICTURE_TYPE_DIB

Returns:Dimension

image dimension in pixels

getResolutionback to summary
public static int[] getResolution(ImageReader r) throws IOException

The metadata of PNG and JPEG can contain the width of a pixel in millimeters. Return the "effective" dpi calculated as 25.4/HorizontalPixelSize and 25.4/VerticalPixelSize. Where 25.4 is the number of mm in inch.

Returns:int[]

array of two elements: {horizontalDpi, verticalDpi}. {96, 96} is the default.

getRowHeightInPixelsback to summary
public static double getRowHeightInPixels(Sheet sheet, int rowNum)
scaleCellback to summary
private static void scaleCell(final double targetSize, final int startCell, final int startD, Consumer<Integer> endCell, Consumer<Integer> endD, final int hssfUnits, Function<Integer, Number> nextSize)
setPreferredSizeback to summary
public static Dimension setPreferredSize(Picture picture, double scaleX, double scaleY)

Calculate and set the preferred size (anchor) for this picture.

Parameters
scaleX:double

the amount by which image width is multiplied relative to the original width.

scaleY:double

the amount by which image height is multiplied relative to the original height.

Returns:Dimension

the new Dimensions of the scaled picture in EMUs

Exceptions
IllegalArgumentException:
if scale values lead to negative or infinite results
IllegalStateException:
if the picture data is corrupt