/** * Translates up to the first 4 bytes of a byte array to a float. * If there are fewer than 4 bytes available, the MSBs are all * assumed to be zero (regardless of endianness). */ public static float bytesToFloat(short[] bytes, boolean little) { return bytesToFloat(bytes, 0, 4, little); }
/** * Translates up to the first 4 bytes of a byte array beyond a given * offset to a float. If there are fewer than 4 bytes available, * the MSBs are all assumed to be zero (regardless of endianness). * * @param bytes array of bytes to be translated to a float * @param off offset to the first byte in the array * @param little true if the bytes are provided in little-endian order * @return the float value that results from concatenating the specified bytes */ public static float bytesToFloat(byte[] bytes, int off, boolean little) { return bytesToFloat(bytes, off, 4, little); }
/** * Translates up to the first 4 bytes of a byte array to a float. * If there are fewer than 4 bytes available, the MSBs are all * assumed to be zero (regardless of endianness). * * @param bytes array of bytes to be translated to a float * @param little true if the bytes are provided in little-endian order * @return the float value that results from concatenating the specified bytes */ public static float bytesToFloat(byte[] bytes, boolean little) { return bytesToFloat(bytes, 0, 4, little); }
/** * Translates up to the first 4 bytes of a byte array to a float. * If there are fewer than 4 bytes available, the MSBs are all * assumed to be zero (regardless of endianness). */ public static float bytesToFloat(byte[] bytes, boolean little) { return bytesToFloat(bytes, 0, 4, little); }
/** * Translates up to the first 4 bytes of a byte array beyond a given * offset to a float. If there are fewer than 4 bytes available, * the MSBs are all assumed to be zero (regardless of endianness). */ public static float bytesToFloat(short[] bytes, int off, boolean little) { return bytesToFloat(bytes, off, 4, little); }
/** * Translates up to the first 4 bytes of a byte array to a float. * If there are fewer than 4 bytes available, the MSBs are all * assumed to be zero (regardless of endianness). * * @param bytes array of unsigned bytes to be translated to a float * @param little true if the bytes are provided in little-endian order * @return the float value that results from concatenating the specified bytes */ public static float bytesToFloat(short[] bytes, boolean little) { return bytesToFloat(bytes, 0, 4, little); }
/** * Translates up to the first 4 bytes of a byte array beyond a given * offset to a float. If there are fewer than 4 bytes available, * the MSBs are all assumed to be zero (regardless of endianness). */ public static float bytesToFloat(byte[] bytes, int off, boolean little) { return bytesToFloat(bytes, off, 4, little); }
/** * Translates up to the first 4 bytes of a byte array beyond a given * offset to a float. If there are fewer than 4 bytes available, * the MSBs are all assumed to be zero (regardless of endianness). * * @param bytes array of unsigned bytes to be translated to a float * @param off offset to the first byte in the array * @param little true if the bytes are provided in little-endian order * @return the float value that results from concatenating the specified bytes */ public static float bytesToFloat(short[] bytes, int off, boolean little) { return bytesToFloat(bytes, off, 4, little); }
for (int x=0; x<width; x++) { int index = 4 * (width * y + x); f[y][x] = bytesToFloat(b, index, 4, little);
for (int x=0; x<width; x++) { int index = 4 * (width * y + x); f[y][x] = bytesToFloat(b, index, 4, little);
int offset = i * BOX_SIZE * bpp * (interleaved ? rgb : 1); if (pixelType == FormatTools.FLOAT) { idx[i] = (int) DataTools.bytesToFloat(plane, offset, bpp, little); } else if (pixelType == FormatTools.DOUBLE) { idx[i] = (int) DataTools.bytesToDouble(plane, offset, bpp, little);
int offset = i * BOX_SIZE * bpp * (interleaved ? rgb : 1); if (pixelType == FormatTools.FLOAT) { idx[i] = (int) DataTools.bytesToFloat(plane, offset, bpp, little); } else if (pixelType == FormatTools.DOUBLE) { idx[i] = (int) DataTools.bytesToDouble(plane, offset, bpp, little);
float[] f = new float[b.length / 4]; for (int i=0; i<f.length; i++) { f[i] = bytesToFloat(b, i * 4, 4, little);
float[] f = new float[b.length / 4]; for (int i=0; i<f.length; i++) { f[i] = bytesToFloat(b, i * 4, 4, little);