ImageExtensions
Inheritance: java.lang.Object
public final class ImageExtensions
Contains extension methods for conversions based on System.Drawing.Image
and Image
.
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The BufferedImage to convert. |
rect | Rectangle | The required rectangle. |
Returns:
RasterImage - The converted PngImage
.
fromJava(BufferedImage image)
public static RasterImage fromJava(BufferedImage image)
Converts the BufferedImage
to the PngImage
.
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The 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:
Parameter | Type | Description |
---|---|---|
image | Image | The 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:
Parameter | Type | Description |
---|---|---|
image | Image | The Image to convert. |
bufferedImageType | int |
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:
Parameter | Type | Description |
---|---|---|
image | Image | The Image to convert. |
subImageRect | Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The 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:
Parameter | Type | Description |
---|---|---|
image | Image | The Image to convert. |
subImageRect | Rectangle | The rectangle of subimage to convert. |
bufferedImageType | int |
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:
Parameter | Type | Description |
---|---|---|
image | Image | The Image to convert. |
subImageRect | Rectangle | The rectangle of sub-image to convert. If subImageRect.isEmpty() whole image will be taken. |
dstImage | java.awt.image.BufferedImage | The destination image. |
Returns:
java.awt.image.BufferedImage - The converted BufferedImage
contains sub-image taken from Image
.