예제 #1
0
 private static int biTypePF(int biType) {
   ByteOrder byteOrder = ByteOrder.nativeOrder();
   switch (biType) {
     case BufferedImage.TYPE_3BYTE_BGR:
       return TJ.PF_BGR;
     case BufferedImage.TYPE_4BYTE_ABGR:
     case BufferedImage.TYPE_4BYTE_ABGR_PRE:
       return TJ.PF_XBGR;
     case BufferedImage.TYPE_BYTE_GRAY:
       return TJ.PF_GRAY;
     case BufferedImage.TYPE_INT_BGR:
       if (byteOrder == ByteOrder.BIG_ENDIAN) return TJ.PF_XBGR;
       else return TJ.PF_RGBX;
     case BufferedImage.TYPE_INT_RGB:
       if (byteOrder == ByteOrder.BIG_ENDIAN) return TJ.PF_XRGB;
       else return TJ.PF_BGRX;
     case BufferedImage.TYPE_INT_ARGB:
     case BufferedImage.TYPE_INT_ARGB_PRE:
       if (byteOrder == ByteOrder.BIG_ENDIAN) return TJ.PF_ARGB;
       else return TJ.PF_BGRA;
   }
   return 0;
 }
예제 #2
0
 /**
  * Same function as in GLApp.java. Allocates a ByteBuffer to hold the given array of bytes.
  *
  * @param bytearray
  * @return ByteBuffer containing the contents of the byte array
  */
 public static ByteBuffer allocBytes(byte[] bytearray) {
   ByteBuffer bb = ByteBuffer.allocateDirect(bytearray.length).order(ByteOrder.nativeOrder());
   bb.put(bytearray).flip();
   return bb;
 }