Package de.alpharogroup.swing.img
Class ImageExtensions
- java.lang.Object
-
- de.alpharogroup.swing.img.ImageExtensions
-
public class ImageExtensions extends java.lang.ObjectThe classImageExtensions.
-
-
Constructor Summary
Constructors Constructor Description ImageExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.image.BufferedImageconcatenateImages(java.util.List<java.awt.image.BufferedImage> imgCollection, int width, int height, int imageType, Direction concatenationDirection)Concatenate the given list of BufferedImage objects to one image and returns the concatenated BufferedImage object.static voidcreatePdf(java.io.OutputStream result, java.util.List<java.awt.image.BufferedImage> images)Creates from the given Collection of images an pdf file.static java.awt.image.BufferedImagegetResized(java.awt.image.BufferedImage originalImage, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given BufferedImage and returns the resized BufferedImage.static java.awt.image.BufferedImagegetResized(java.awt.image.BufferedImage originalImage, org.imgscalr.Scalr.Method scalingMethod, org.imgscalr.Scalr.Mode resizeMode, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given BufferedImage and returns the resized BufferedImage.static javax.swing.ImageIconnewImageIcon(java.io.File image)Factory method for create a newImageIcon.static com.itextpdf.text.pdf.PdfPTablenewPdfPTable(int numColumns, java.util.List<java.lang.String> headerNames)Factory method for create a newPdfPTablewith the given count of columns and the column header namesstatic java.awt.image.BufferedImagerandomBufferedImage(int width, int height, int imageType)Generates a randomBufferedImagewith the given parameters.static java.awt.image.BufferedImageread(byte[] byteArray)Gets the buffered image from the given byte array.static java.awt.image.BufferedImagereadQuietly(byte[] byteArray)Gets the buffered image from the given byte array quietly.static java.awt.image.BufferedImagereadQuietly(java.io.InputStream input)Gets the buffered image from the given byte array quietly.static byte[]resize(java.awt.image.BufferedImage originalImage, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given BufferedImage.static byte[]resize(java.awt.image.BufferedImage originalImage, org.imgscalr.Scalr.Method scalingMethod, org.imgscalr.Scalr.Mode resizeMode, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given image.static byte[]toByteArray(java.awt.image.BufferedImage bi, java.lang.String formatName)Converts the given BufferedImage to a byte array.static java.lang.StringunweaveFrom(java.awt.image.BufferedImage bufferedImage)Unweave a secret message from the givenBufferedImage.static java.awt.image.BufferedImageweaveInto(java.awt.image.BufferedImage bufferedImage, java.lang.String message)Weave the given secret message into the givenBufferedImage.static java.io.Filewrite(java.awt.image.BufferedImage bufferedImage, java.lang.String formatName, java.io.File outputfile)Convenience method to write the givenBufferedImageobject to the givenFileobject.
-
-
-
Method Detail
-
concatenateImages
public static java.awt.image.BufferedImage concatenateImages(java.util.List<java.awt.image.BufferedImage> imgCollection, int width, int height, int imageType, Direction concatenationDirection)Concatenate the given list of BufferedImage objects to one image and returns the concatenated BufferedImage object.- Parameters:
imgCollection- the BufferedImage collectionwidth- the width of the image that will be returned.height- the height of the image that will be returned.imageType- type of the created imageconcatenationDirection- the direction of the concatenation.- Returns:
- the buffered image
-
createPdf
public static void createPdf(java.io.OutputStream result, java.util.List<java.awt.image.BufferedImage> images) throws com.itextpdf.text.DocumentException, java.io.IOExceptionCreates from the given Collection of images an pdf file.- Parameters:
result- the output stream from the pdf file where the images shell be written.images- the BufferedImage collection to be written in the pdf file.- Throws:
com.itextpdf.text.DocumentException- is thrown if an error occurs when trying to get an instance ofPdfWriter.java.io.IOException- Signals that an I/O exception has occurred.
-
getResized
public static java.awt.image.BufferedImage getResized(java.awt.image.BufferedImage originalImage, org.imgscalr.Scalr.Method scalingMethod, org.imgscalr.Scalr.Mode resizeMode, java.lang.String formatName, int targetWidth, int targetHeight) throws java.io.IOExceptionResize the given BufferedImage and returns the resized BufferedImage.- Parameters:
originalImage- the original imagescalingMethod- the scaling methodresizeMode- the resize modeformatName- the format nametargetWidth- the target widthtargetHeight- the target height- Returns:
- the resized
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
getResized
public static java.awt.image.BufferedImage getResized(java.awt.image.BufferedImage originalImage, java.lang.String formatName, int targetWidth, int targetHeight) throws java.io.IOExceptionResize the given BufferedImage and returns the resized BufferedImage.- Parameters:
originalImage- the original imageformatName- the format nametargetWidth- the target widthtargetHeight- the target height- Returns:
- the resized
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
newImageIcon
public static javax.swing.ImageIcon newImageIcon(java.io.File image)
Factory method for create a newImageIcon.- Parameters:
image- the file that contains the image- Returns:
- the new
ImageIcon
-
newPdfPTable
public static com.itextpdf.text.pdf.PdfPTable newPdfPTable(int numColumns, java.util.List<java.lang.String> headerNames)Factory method for create a newPdfPTablewith the given count of columns and the column header names- Parameters:
numColumns- the count of columns of the tableheaderNames- the column header names- Returns:
- the new
PdfPTable
-
randomBufferedImage
public static java.awt.image.BufferedImage randomBufferedImage(int width, int height, int imageType)Generates a randomBufferedImagewith the given parameters.- Parameters:
width- the widthheight- the heightimageType- the type of the image- Returns:
- The generated
BufferedImage.
-
read
public static java.awt.image.BufferedImage read(byte[] byteArray) throws java.io.IOExceptionGets the buffered image from the given byte array.- Parameters:
byteArray- the byte array- Returns:
- the buffered image
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
readQuietly
public static java.awt.image.BufferedImage readQuietly(byte[] byteArray)
Gets the buffered image from the given byte array quietly.- Parameters:
byteArray- the byte array- Returns:
- the buffered image or null if the read process failed.
-
readQuietly
public static java.awt.image.BufferedImage readQuietly(java.io.InputStream input)
Gets the buffered image from the given byte array quietly.- Parameters:
input- the input- Returns:
- the buffered image or null if the read process failed.
-
resize
public static byte[] resize(java.awt.image.BufferedImage originalImage, org.imgscalr.Scalr.Method scalingMethod, org.imgscalr.Scalr.Mode resizeMode, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given image.- Parameters:
originalImage- the original imagescalingMethod- the scaling methodresizeMode- the resize modeformatName- the format nametargetWidth- the target widthtargetHeight- the target height- Returns:
- the byte[]
-
resize
public static byte[] resize(java.awt.image.BufferedImage originalImage, java.lang.String formatName, int targetWidth, int targetHeight)Resize the given BufferedImage.- Parameters:
originalImage- the original imageformatName- the format nametargetWidth- the target widthtargetHeight- the target height- Returns:
- the byte[]
-
toByteArray
public static byte[] toByteArray(java.awt.image.BufferedImage bi, java.lang.String formatName) throws java.io.IOExceptionConverts the given BufferedImage to a byte array.- Parameters:
bi- the biformatName- the format name- Returns:
- the byte[]
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
unweaveFrom
public static java.lang.String unweaveFrom(java.awt.image.BufferedImage bufferedImage)
Unweave a secret message from the givenBufferedImage.- Parameters:
bufferedImage- the buffered image- Returns:
- the secret message
-
weaveInto
public static java.awt.image.BufferedImage weaveInto(java.awt.image.BufferedImage bufferedImage, java.lang.String message)Weave the given secret message into the givenBufferedImage.- Parameters:
bufferedImage- the buffered imagemessage- the secret message- Returns:
- the buffered image with the secret message weaved in.
-
write
public static java.io.File write(java.awt.image.BufferedImage bufferedImage, java.lang.String formatName, java.io.File outputfile) throws java.io.IOExceptionConvenience method to write the givenBufferedImageobject to the givenFileobject.- Parameters:
bufferedImage- theBufferedImageobject to be written.formatName- the format nameoutputfile- the output file- Returns:
- the file
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-