Package panamagl.renderers.image
Class BufferedImageForeign
java.lang.Object
panamagl.renderers.image.BufferedImageForeign
Convert AWT
Images to MemorySegment or int[] pixel buffers suitable
for direct OpenGL rendering via GL_1_0.glDrawPixels(int, int, int, int, MemorySegment).- Author:
- Martin Pernollet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MemorySegmentallocBytes(byte[] byteArray) Allocates ato hold the given array of bytes.invalid reference
ByteBufferstatic byte[]convertARGBtoRGBA(int[] pixels) Convert pixels from java default ARGB int format to byte array in RGBA format.static MemorySegmentconvertARGBtoRGBA(int[] pixels, int width, int height, boolean flipVertically) Convert ARGB pixels to aMemorySegmentcontaining RGBA pixels.static int[]flipPixels(int[] imgPixels, int imgw, int imgh) Flip an array of pixels verticallystatic 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) static MemorySegmenttoMemorySegment(Image image) static MemorySegmenttoMemorySegment(Image image, int width, int height) Create acontaining a RGBA pixels out of an Image made of ARGB pixels.invalid reference
ByteBuffer
-
Constructor Details
-
BufferedImageForeign
public BufferedImageForeign()
-
-
Method Details
-
toMemorySegment
-
toMemorySegment
Create acontaining a RGBA pixels out of an Image made of ARGB pixels. The buffer can later be drawn byinvalid reference
ByteBufferGL2.glDrawPixels(imgW, imgH, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, byteBuffer);- Parameters:
image-width-height-- Returns:
-
getImagePixels
-
getImagePixels
Return the image pixels in default Java int ARGB format.- Parameters:
image-width-height-- Returns:
-
convertARGBtoRGBA
public static MemorySegment convertARGBtoRGBA(int[] pixels, int width, int height, boolean flipVertically) Convert ARGB pixels to aMemorySegmentcontaining RGBA pixels. Can be drawn in ORTHO mode using:GL2.glDrawPixels(imgW, imgH, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, segment);If flipVertically is true, pixels will be flipped vertically for OpenGL coord system.- Parameters:
imgFilename-- Returns:
- MemorySegment
-
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 ato hold the given array of bytes.invalid reference
ByteBuffer- Parameters:
byteArray-- Returns:
- ByteBuffer containing the contents of the byte array
-