ImageExtensions

Inheritance: java.lang.Object

public final class ImageExtensions

Contains extension methods for conversions based on System.Drawing.Image and Image.

Methods

MethodDescription
fromJava(BufferedImage image, Rectangle rect)Converts the BufferedImage to the PngImage.
fromJava(BufferedImage image)Converts the BufferedImage to the PngImage.
toJava(Image image)Converts the Image to the BufferedImage with TYPE_INT_ARGB.
toJava(Image image, int bufferedImageType)Converts the Image to the BufferedImage with bufferedImageType.
toJava(Image image, Rectangle subImageRect)Takes the subimage from Image and converts to the BufferedImage with BufferedImage.TYPE_INT_ARGB.
wrap(BufferedImage image)Create a wrapper over the BufferedImage without copying the pixels data.
toJava(Image image, Rectangle subImageRect, int bufferedImageType)Takes the subimage from Image and converts to the BufferedImage with bufferedImageType.
toJava(Image image, Rectangle subImageRect, BufferedImage dstImage)Takes the subimage from Image and converts to the BufferedImage with bufferedImageType.

fromJava(BufferedImage image, Rectangle rect)

public static RasterImage fromJava(BufferedImage image, Rectangle rect)

Converts the BufferedImage to the PngImage.

Warning, the GDI image may get lower bounds than image has. To get all parts of the image use more safe extension method ToGdiImageFull.

Parameters:

ParameterTypeDescription
imagejava.awt.image.BufferedImageThe BufferedImage to convert.
rectRectangleThe required rectangle.

Returns: RasterImage - The converted PngImage.

fromJava(BufferedImage image)

public static RasterImage fromJava(BufferedImage image)

Converts the BufferedImage to the PngImage.

Parameters:

ParameterTypeDescription
imagejava.awt.image.BufferedImageThe BufferedImage to convert.

Returns: RasterImage - The converted PngImage.

toJava(Image image)

public static BufferedImage toJava(Image image)

Converts the Image to the BufferedImage with TYPE_INT_ARGB.

Parameters:

ParameterTypeDescription
imageImageThe Image to convert.

Returns: java.awt.image.BufferedImage - The converted BufferedImage.

toJava(Image image, int bufferedImageType)

public static BufferedImage toJava(Image image, int bufferedImageType)

Converts the Image to the BufferedImage with bufferedImageType. Please choose bufferedImageType from java.awt.image.BufferedImage#TYPE_****

Parameters:

ParameterTypeDescription
imageImageThe Image to convert.
bufferedImageTypeint

Returns: java.awt.image.BufferedImage - The converted BufferedImage.

toJava(Image image, Rectangle subImageRect)

public static BufferedImage toJava(Image image, Rectangle subImageRect)

Takes the subimage from Image and converts to the BufferedImage with BufferedImage.TYPE_INT_ARGB.

Parameters:

ParameterTypeDescription
imageImageThe Image to convert.
subImageRectRectangleThe rectangle of subimage to convert.

Returns: java.awt.image.BufferedImage - The converted BufferedImage contains subimage taken from Image.

wrap(BufferedImage image)

public static RasterImage wrap(BufferedImage image)

Create a wrapper over the BufferedImage without copying the pixels data. It uses the source image under the hood but allows to manipulate with it as with a RasterImage.

Parameters:

ParameterTypeDescription
imagejava.awt.image.BufferedImageThe source image.

Returns: RasterImage - The wrapper RasterImage.

toJava(Image image, Rectangle subImageRect, int bufferedImageType)

public static BufferedImage toJava(Image image, Rectangle subImageRect, int bufferedImageType)

Takes the subimage from Image and converts to the BufferedImage with bufferedImageType. Please choose bufferedImageType from java.awt.image.BufferedImage#TYPE_****

Parameters:

ParameterTypeDescription
imageImageThe Image to convert.
subImageRectRectangleThe rectangle of subimage to convert.
bufferedImageTypeint

Returns: java.awt.image.BufferedImage - The converted BufferedImage contains subimage taken from Image.

toJava(Image image, Rectangle subImageRect, BufferedImage dstImage)

public static BufferedImage toJava(Image image, Rectangle subImageRect, BufferedImage dstImage)

Takes the subimage from Image and converts to the BufferedImage with bufferedImageType. Please choose bufferedImageType from java.awt.image.BufferedImage#TYPE_****

Parameters:

ParameterTypeDescription
imageImageThe Image to convert.
subImageRectRectangleThe rectangle of sub-image to convert. If subImageRect.isEmpty() whole image will be taken.
dstImagejava.awt.image.BufferedImageThe destination image.

Returns: java.awt.image.BufferedImage - The converted BufferedImage contains sub-image taken from Image.