Class PixelFormatUtil

java.lang.Object
com.jogamp.nativewindow.util.PixelFormatUtil

public class PixelFormatUtil extends Object
Pixel Rectangle Utilities.

All conversion methods are endian independent.

  • Constructor Details

    • PixelFormatUtil

      public PixelFormatUtil()
  • Method Details

    • find

      public static final int find(PixelFormat.CType s, PixelFormat.CType[] pool, boolean mapRGB2Y)
    • getShiftedI32

      public static int getShiftedI32(int bytesPerPixel, byte[] data, int offset)
      Returns shifted bytes from the given data at given offset of maximal 4 bytesPerPixel.
      Parameters:
      bytesPerPixel - number of bytes per pixel to fetch, a maximum of 4 are allowed
      data - byte buffer covering complete pixel at position offset
      offset - byte offset of pixel data start
      Returns:
      the shifted 32bit integer value of the pixel
    • getShiftedI64

      public static long getShiftedI64(int bytesPerPixel, byte[] data, int offset)
      Returns shifted bytes from the given data at given offset of maximal 8 bytesPerPixel.
      Parameters:
      bytesPerPixel - number of bytes per pixel to fetch, a maximum of 4 are allowed
      data - byte buffer covering complete pixel at position offset
      offset - byte offset of pixel data start
      Returns:
      the shifted 64bit integer value of the pixel
    • getShiftedI32

      public static int getShiftedI32(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
      Returns shifted bytes from the given data at current position of maximal 4 bytesPerPixel.
      Parameters:
      bytesPerPixel - number of bytes per pixel to fetch, a maximum of 4 are allowed
      data - byte buffer covering complete pixel at position offset
      retainDataPos - if true, absolute ByteBuffer.get(int) is used and the data position stays unchanged. Otherwise relative ByteBuffer.get() is used and the data position changes.
      Returns:
      the shifted 32bit integer value of the pixel
    • getShiftedI64

      public static long getShiftedI64(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
      Returns shifted bytes from the given data at current position of maximal 8 bytesPerPixel.
      Parameters:
      bytesPerPixel - number of bytes per pixel to fetch, a maximum of 4 are allowed
      data - byte buffer covering complete pixel at position offset
      retainDataPos - if true, absolute ByteBuffer.get(int) is used and the data position stays unchanged. Otherwise relative ByteBuffer.get() is used and the data position changes.
      Returns:
      the shifted 64bit integer value of the pixel
    • getReversed

      public static PixelFormat getReversed(PixelFormat fmt)
      Returns the PixelFormat with reversed components of fmt. If no reversed PixelFormat is available, returns fmt.
    • convertToInt32

      public static int convertToInt32(PixelFormat dst_fmt, byte r, byte g, byte b, byte a)
    • convertToInt32

      public static int convertToInt32(PixelFormat dst_fmt, PixelFormat src_fmt, ByteBuffer src, int srcOff)
    • convertToInt32

      public static int convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, int src_pixel)
    • convert

      public static PixelRectangle convert(PixelRectangle src, PixelFormat destFmt, int ddestStride, boolean isGLOriented, boolean destIsDirect)
    • convert

      public static void convert(PixelRectangle src, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride) throws IllegalStateException
      Parameters:
      src -
      dst_bb - ByteBuffer sink
      dst_fmt - destination PixelFormat
      dst_glOriented - if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
      dst_lineStride - line stride in byte-size for destination, i.e. byte count from one line to the next. Must be >= dst_fmt.comp.bytesPerPixel() * width or zero for default stride.
      Throws:
      IllegalStateException
      IllegalArgumentException - if src_lineStride or dst_lineStride is invalid
    • convert

      public static void convert(int width, int height, ByteBuffer src_bb, PixelFormat src_fmt, boolean src_glOriented, int src_lineStride, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride) throws IllegalStateException, IllegalArgumentException
      Parameters:
      width - width of the to be converted pixel rectangle
      height - height of the to be converted pixel rectangle
      src_bb - ByteBuffer source
      src_fmt - source PixelFormat
      src_glOriented - if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
      src_lineStride - line stride in byte-size for source, i.e. byte count from one line to the next. Must be >= src_fmt.comp.bytesPerPixel() * width or zero for default stride.
      dst_bb - ByteBuffer sink
      dst_fmt - destination PixelFormat
      dst_glOriented - if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
      dst_lineStride - line stride in byte-size for destination, i.e. byte count from one line to the next. Must be >= dst_fmt.comp.bytesPerPixel() * width or zero for default stride.
      Throws:
      IllegalStateException
      IllegalArgumentException - if src_lineStride or dst_lineStride is invalid
    • convert

      public static void convert(PixelFormatUtil.ComponentMap cmap, PixelFormat.Composition dstComp, com.jogamp.common.util.Bitstream<ByteBuffer> dstBitStream, PixelFormat.Composition srcComp, com.jogamp.common.util.Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException
      Throws:
      IllegalStateException
      IOException