Package org.jzy3d.plot3d.rendering.image
Class AWTImageConvert
java.lang.Object
org.jzy3d.plot3d.rendering.image.AWTImageConvert
Convert AWT
Images to ByteBuffer or int[] pixel buffers suitable for
direct OpenGL rendering via IPainter.glDrawPixels(int, int, int, int, Buffer).- Author:
- Martin
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferallocBytes(byte[] byteArray) Allocates aByteBufferto 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 ByteBufferconvertARGBtoRGBA(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 ByteBuffergetByteBuffer(Image img, int width, int height) Return aByteBufferout of the image.static ByteBuffergetImageAsByteBuffer(Image image) static ByteBuffergetImageAsByteBuffer(Image image, int width, int height) Create aByteBuffercontaining 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 aByteBuffercontaining 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 aByteBufferto hold the given array of bytes.- Parameters:
byteArray-- Returns:
- ByteBuffer containing the contents of the byte array
-
getByteBuffer
Return aByteBufferout 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:
-