Package org.apache.poi.ss.util
Class ImageUtils
java.lang.Object
org.apache.poi.ss.util.ImageUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic DimensiongetDimensionFromAnchor(ClientAnchor anchor, Sheet sheet) Calculates the dimensions in EMUs for the given anchor in the context of the given sheet.static DimensiongetDimensionFromAnchor(Picture picture) Calculates the dimensions in EMUs for the anchor of the given picturestatic DimensiongetImageDimension(InputStream is, int type) Return the dimension of this imagestatic int[]The metadata of PNG and JPEG can contain the width of a pixel in millimeters.static doublegetRowHeightInPixels(Sheet sheet, int rowNum) static DimensionsetPreferredSize(Picture picture, double scaleX, double scaleY) Calculate and set the preferred size (anchor) for this picture.
-
Method Details
-
getImageDimension
Return the dimension of this image- Parameters:
is- the stream containing the image datatype- type of the picture:Workbook.PICTURE_TYPE_JPEG,Workbook.PICTURE_TYPE_PNGorWorkbook.PICTURE_TYPE_DIB- Returns:
- image dimension in pixels
-
getResolution
The metadata of PNG and JPEG can contain the width of a pixel in millimeters. Return the "effective" dpi calculated as25.4/HorizontalPixelSizeand25.4/VerticalPixelSize. Where 25.4 is the number of mm in inch.- Returns:
- array of two elements:
{horizontalDpi, verticalDpi}. {96, 96} is the default. - Throws:
IOException
-
setPreferredSize
Calculate and set the preferred size (anchor) for this picture.- Parameters:
scaleX- the amount by which image width is multiplied relative to the original width.scaleY- the amount by which image height is multiplied relative to the original height.- Returns:
- the new Dimensions of the scaled picture in EMUs
- Throws:
IllegalArgumentException- if scale values lead to negative or infinite resultsIllegalStateException- if the picture data is corrupt
-
getDimensionFromAnchor
Calculates the dimensions in EMUs for the anchor of the given picture- Parameters:
picture- the picture containing the anchor- Returns:
- the dimensions in EMUs
-
getDimensionFromAnchor
Calculates the dimensions in EMUs for the given anchor in the context of the given sheet.- Parameters:
anchor- the anchor of which we want to calculate the dimensions.sheet- the sheet where the anchor is inserted; it's required to obtain the cell width/height necessary to calculate the dimensions of the anchor.- Returns:
- the dimensions in EMUs
- Since:
- 6.0.0
-
getRowHeightInPixels
-