Package org.jzy3d.plot3d.rendering.image
Class AWTImageConvert
java.lang.Object
org.jzy3d.plot3d.rendering.image.AWTImageConvert
Convert AWT
Image
s to ByteBuffer
or int[]
pixel buffers suitable for
direct OpenGL rendering via IPainter.glDrawPixels(int, int, int, int, Buffer)
.- Author:
- Martin
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
SIZE_BYTE
protected static final int SIZE_BYTE- See Also:
-
-
Constructor Details
-
AWTImageConvert
public AWTImageConvert()
-
-
Method Details
-
getImageAsByteBuffer
-
getImagePixels
-
getImageAsByteBuffer
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
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
Allocates aByteBuffer
to hold the given array of bytes.- Parameters:
byteArray
-- Returns:
- ByteBuffer containing the contents of the byte array
-
getByteBuffer
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:
-