/** Translates the short value into an array of two bytes. */ public static byte[] shortToBytes(short value, boolean little) { byte[] v = new byte[2]; unpackBytes(value, v, 0, 2, little); return v; }
/** Translates the long value into an array of eight bytes. */ public static byte[] longToBytes(long value, boolean little) { byte[] v = new byte[8]; unpackBytes(value, v, 0, 8, little); return v; }
/** * Translates the int value into an array of four bytes. * * @param value the int to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length 4 */ public static byte[] intToBytes(int value, boolean little) { byte[] v = new byte[4]; unpackBytes(value, v, 0, 4, little); return v; }
/** * Translates the short value into an array of two bytes. * * @param value the short to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length 2 */ public static byte[] shortToBytes(short value, boolean little) { byte[] v = new byte[2]; unpackBytes(value, v, 0, 2, little); return v; }
/** Translates an array of long values into an array of byte values. */ public static byte[] longsToBytes(long[] values, boolean little) { byte[] v = new byte[values.length * 8]; for (int i=0; i<values.length; i++) { unpackBytes(values[i], v, i * 8, 8, little); } return v; }
/** * Translates the long value into an array of eight bytes. * * @param value the long to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length 8 */ public static byte[] longToBytes(long value, boolean little) { byte[] v = new byte[8]; unpackBytes(value, v, 0, 8, little); return v; }
/** Translates the int value into an array of four bytes. */ public static byte[] intToBytes(int value, boolean little) { byte[] v = new byte[4]; unpackBytes(value, v, 0, 4, little); return v; }
/** Translates an array of short values into an array of byte values. */ public static byte[] shortsToBytes(short[] values, boolean little) { byte[] v = new byte[values.length * 2]; for (int i=0; i<values.length; i++) { unpackBytes(values[i], v, i * 2, 2, little); } return v; }
/** Translates an array of int values into an array of byte values. */ public static byte[] intsToBytes(int[] values, boolean little) { byte[] v = new byte[values.length * 4]; for (int i=0; i<values.length; i++) { unpackBytes(values[i], v, i * 4, 4, little); } return v; }
/** * Translates an array of int values into an array of byte values. * * @param values the ints to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length <code>4 * values.length</code> */ public static byte[] intsToBytes(int[] values, boolean little) { byte[] v = new byte[values.length * 4]; for (int i=0; i<values.length; i++) { unpackBytes(values[i], v, i * 4, 4, little); } return v; }
/** * Translates an array of long values into an array of byte values. * * @param values the longs to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length <code>8 * values.length</code> */ public static byte[] longsToBytes(long[] values, boolean little) { byte[] v = new byte[values.length * 8]; for (int i=0; i<values.length; i++) { unpackBytes(values[i], v, i * 8, 8, little); } return v; }
/** * Translates the float value into an array of four bytes. * * @param value the float to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length 4 */ public static byte[] floatToBytes(float value, boolean little) { byte[] v = new byte[4]; unpackBytes(Float.floatToIntBits(value), v, 0, 4, little); return v; }
/** Translates an array of double values into an array of byte values. */ public static byte[] doublesToBytes(double[] values, boolean little) { byte[] v = new byte[values.length * 8]; for (int i=0; i<values.length; i++) { unpackBytes(Double.doubleToLongBits(values[i]), v, i * 8, 8, little); } return v; }
/** Translates an array of float values into an array of byte values. */ public static byte[] floatsToBytes(float[] values, boolean little) { byte[] v = new byte[values.length * 4]; for (int i=0; i<values.length; i++) { unpackBytes(Float.floatToIntBits(values[i]), v, i * 4, 4, little); } return v; }
/** * Translates the double value into an array of eight bytes. * * @param value the double to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length 8 */ public static byte[] doubleToBytes(double value, boolean little) { byte[] v = new byte[8]; unpackBytes(Double.doubleToLongBits(value), v, 0, 8, little); return v; }
/** Translates the float value into an array of four bytes. */ public static byte[] floatToBytes(float value, boolean little) { byte[] v = new byte[4]; unpackBytes(Float.floatToIntBits(value), v, 0, 4, little); return v; }
/** Translates the double value into an array of eight bytes. */ public static byte[] doubleToBytes(double value, boolean little) { byte[] v = new byte[8]; unpackBytes(Double.doubleToLongBits(value), v, 0, 8, little); return v; }
/** * Translates an array of float values into an array of byte values. * * @param values the floats to be split into bytes * @param little true if the returned bytes should be in little-endian order * @return byte array with length <code>4 * values.length</code> */ public static byte[] floatsToBytes(float[] values, boolean little) { byte[] v = new byte[values.length * 4]; for (int i=0; i<values.length; i++) { unpackBytes(Float.floatToIntBits(values[i]), v, i * 4, 4, little); } return v; }
private byte[] getFixedHeader() throws IOException { in.seek(offset); byte[] header = new byte[(int) (sos - offset)]; in.read(header); int index = (int) (imageDimensions - offset); DataTools.unpackBytes(tileDim, header, index, 2, false); DataTools.unpackBytes(tileDim, header, index + 2, 2, false); return header; }
private byte[] getFixedHeader() throws IOException { in.seek(offset); byte[] header = new byte[(int) (sos - offset)]; in.read(header); int index = (int) (imageDimensions - offset); DataTools.unpackBytes(tileDim, header, index, 2, false); DataTools.unpackBytes(tileDim, header, index + 2, 2, false); return header; }