Package org.jzy3d.plot3d.rendering.image
Class AWTImageConvert
- java.lang.Object
-
- org.jzy3d.plot3d.rendering.image.AWTImageConvert
-
public class AWTImageConvert extends Object
Convert AWTImage
s toByteBuffer
orint[]
pixel buffers suitable for direct OpenGL rendering viaIPainter.glDrawPixels(int, int, int, int, Buffer)
.- Author:
- Martin
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
SIZE_BYTE
-
Constructor Summary
Constructors Constructor Description AWTImageConvert()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ByteBuffer
allocBytes(byte[] byteArray)
Allocates aByteBuffer
to hold the given array of bytes.static byte[]
convertARGBtoRGBA(int[] pixels)
Convert pixels from java default ARGB int format to byte array in RGBA format.static ByteBuffer
convertARGBtoRGBA(int[] pixels, int width, int height, boolean flipVertically)
Convert ARGB pixels to a ByteBuffer containing RGBA pixels.static int[]
flipPixels(int[] imgPixels, int imgw, int imgh)
Flip an array of pixels verticallystatic ByteBuffer
getByteBuffer(Image img, int width, int height)
Return aByteBuffer
out of the image.static ByteBuffer
getImageAsByteBuffer(Image image)
static ByteBuffer
getImageAsByteBuffer(Image image, int width, int height)
Create aByteBuffer
containing a RGBA pixels out of an Image made of ARGB pixels.static int[]
getImagePixels(Image image)
static int[]
getImagePixels(Image image, int width, int height)
Return the image pixels in default Java int ARGB format.static byte[]
getRGBABytes(int[] pixels)
-
-
-
Field Detail
-
SIZE_BYTE
protected static final int SIZE_BYTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getImageAsByteBuffer
public static ByteBuffer getImageAsByteBuffer(Image image)
-
getImagePixels
public static int[] getImagePixels(Image image)
-
getImageAsByteBuffer
public static ByteBuffer getImageAsByteBuffer(Image image, int width, int height)
Create aByteBuffer
containing a RGBA pixels out of an Image made of ARGB pixels. The buffer can later be drawn byGL2.glDrawPixels(imgW, imgH, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, byteBuffer);
- Parameters:
image
-width
-height
-- Returns:
-
getImagePixels
public static int[] getImagePixels(Image image, int width, int height)
Return the image pixels in default Java int ARGB format.- Parameters:
image
-width
-height
-- Returns:
-
convertARGBtoRGBA
public static ByteBuffer convertARGBtoRGBA(int[] pixels, int width, int height, boolean flipVertically)
Convert ARGB pixels to a ByteBuffer containing RGBA pixels. Can be drawn in ORTHO mode using:GL2.glDrawPixels(imgW, imgH, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, byteBuffer);
If flipVertically is true, pixels will be flipped vertically for OpenGL coord system.- Parameters:
imgFilename
-- Returns:
- ByteBuffer
-
convertARGBtoRGBA
public static byte[] convertARGBtoRGBA(int[] pixels)
Convert pixels from java default ARGB int format to byte array in RGBA format.- Parameters:
pixels
-- Returns:
-
getRGBABytes
public static byte[] getRGBABytes(int[] pixels)
-
flipPixels
public static int[] flipPixels(int[] imgPixels, int imgw, int imgh)
Flip an array of pixels vertically- Parameters:
imgPixels
-imgw
-imgh
-- Returns:
- int[]
-
allocBytes
public static ByteBuffer allocBytes(byte[] byteArray)
Allocates aByteBuffer
to hold the given array of bytes.- Parameters:
byteArray
-- Returns:
- ByteBuffer containing the contents of the byte array
-
getByteBuffer
public static ByteBuffer getByteBuffer(Image img, int width, int height)
Return aByteBuffer
out of the image. Not used in the framework. Look rather forgetImageAsByteBuffer(Image, int, int)
that has same signature and more used implementation.- Parameters:
img
-width
-height
-- Returns:
-
-