Package com.snowbound.common.utils
Class ImageUtils
- java.lang.Object
-
- com.snowbound.common.utils.ImageUtils
-
public class ImageUtils extends java.lang.Object
Contains utility methods used for sizing and adjusting images.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
adjustForXYDPI(RasterMaster snowImage)
This method resizes an image that has an X-DPI that is different the Y-DPI.static int
getAdjustedHeightForYDPI(RasterMaster snowImage)
Returns height of image adjusted to match the X-DPI (instead of the Y-DPI).static int
getLargeImageScaleFactor(int width, int height, int bitDepth, long maxImageSize)
Call if scaling is configured (rpConfig.isScalingConfigured()) to determine the scale factor.static java.awt.Dimension
getThumbnailSize(int maxDimension, int imageWidth, int imageHeight, int xDPI, int yDPI)
Calculate the best dimensions for a thumbnail of a document page with the given width, height, and DPI.static byte[]
increaseBytes(byte[] inByte)
Return a new byte array with the same contents, double the size of the original.static byte[]
trimBytes(byte[] inByte, int realSize)
Trim provided array to the provided size.
-
-
-
Method Detail
-
getThumbnailSize
public static java.awt.Dimension getThumbnailSize(int maxDimension, int imageWidth, int imageHeight, int xDPI, int yDPI)
Calculate the best dimensions for a thumbnail of a document page with the given width, height, and DPI.- Parameters:
maxDimension
- maximum size thumbnail can be scaled to - either width or height, depending on the original image's aspect ratioimageWidth
- original image's widthimageHeight
- original image's heightxDPI
- horizontal dots per inchyDPI
- vertical dots per inch- Returns:
- Dimension object containing width and height
-
adjustForXYDPI
public static boolean adjustForXYDPI(RasterMaster snowImage) throws java.lang.InterruptedException
This method resizes an image that has an X-DPI that is different the Y-DPI. If a resize is necessary, then the Y-DPI will also be updated to match the X-DPI.- Parameters:
snowImage
- RasterMaster object containing the image to scale- Returns:
- true if an adjustment was made.
- Throws:
java.lang.InterruptedException
- if the calling thread is interrupted
-
getAdjustedHeightForYDPI
public static int getAdjustedHeightForYDPI(RasterMaster snowImage)
Returns height of image adjusted to match the X-DPI (instead of the Y-DPI). Will return the original height if both DPIs match.- Parameters:
snowImage
- RasterMaster object containing the image to measure- Returns:
- adjusted height measured by X-DPI
-
increaseBytes
public static byte[] increaseBytes(byte[] inByte)
Return a new byte array with the same contents, double the size of the original.- Parameters:
inByte
- byte array to copy and double- Returns:
- equivalent byte array of double the size
-
trimBytes
public static byte[] trimBytes(byte[] inByte, int realSize)
Trim provided array to the provided size.- Parameters:
inByte
- array to trimrealSize
- size to trim array to- Returns:
- trimmed array
-
getLargeImageScaleFactor
public static int getLargeImageScaleFactor(int width, int height, int bitDepth, long maxImageSize)
Call if scaling is configured (rpConfig.isScalingConfigured()) to determine the scale factor. This is only called for images/text rects going to the client, not being exported etc- Parameters:
width
- Width of the image in pixelsheight
- Height of the image in pixelsbitDepth
- Bitdepth of the imagemaxImageSize
- The maximum image size-- width times height -- that should be sent to the client- Returns:
- An integer scale factor, to be used in the denominator
-
-