Class AWTImageConvert

java.lang.Object
org.jzy3d.plot3d.rendering.image.AWTImageConvert

public class AWTImageConvert extends Object
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 Details

  • Constructor Details

    • AWTImageConvert

      public AWTImageConvert()
  • Method Details

    • 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 a ByteBuffer containing a RGBA pixels out of an Image made of ARGB pixels. The buffer can later be drawn by GL2.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 a ByteBuffer 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 a ByteBuffer out of the image. Not used in the framework. Look rather for getImageAsByteBuffer(Image, int, int) that has same signature and more used implementation.
      Parameters:
      img -
      width -
      height -
      Returns: