Class ImageUtils


  • public final class ImageUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Dimension getDimensionFromAnchor​(Picture picture)
      Calculates the dimensions in EMUs for the anchor of the given picture
      static java.awt.Dimension getImageDimension​(java.io.InputStream is, int type)
      Return the dimension of this image
      static int[] getResolution​(javax.imageio.ImageReader r)
      The metadata of PNG and JPEG can contain the width of a pixel in millimeters.
      static double getRowHeightInPixels​(Sheet sheet, int rowNum)  
      static java.awt.Dimension setPreferredSize​(Picture picture, double scaleX, double scaleY)
      Calculate and set the preferred size (anchor) for this picture.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getResolution

        public static int[] getResolution​(javax.imageio.ImageReader r)
                                   throws java.io.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:
        array of two elements: {horizontalDpi, verticalDpi}. {96, 96} is the default.
        Throws:
        java.io.IOException
      • setPreferredSize

        public static java.awt.Dimension setPreferredSize​(Picture picture,
                                                          double scaleX,
                                                          double scaleY)
        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:
        java.lang.IllegalArgumentException - if scale values lead to negative or infinite results
      • getDimensionFromAnchor

        public static java.awt.Dimension getDimensionFromAnchor​(Picture picture)
        Calculates the dimensions in EMUs for the anchor of the given picture
        Parameters:
        picture - the picture containing the anchor
        Returns:
        the dimensions in EMUs
      • getRowHeightInPixels

        public static double getRowHeightInPixels​(Sheet sheet,
                                                  int rowNum)