/** * Convenience method for creating a float array from a byte array. * * @param data * @return */ public static float[] toFloatArray(byte[] data) { float[] result = new float[data.length / 4]; byte[] tmp = new byte[4]; for (int i = 0; i < result.length; i++) { System.arraycopy(data, i * 4, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
/** * Convenience method for creating a float array from a byte array. * * @param in * @param offset * @param length * @return */ public static float[] toFloatArray(byte[] in, int offset, int length) { float[] result = new float[length / 4]; byte[] tmp = new byte[4]; for (int i = offset; i < length / 4; i++) { System.arraycopy(in, (i - offset) * 4 + offset, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
/** * Convenience method for creating a float array from a byte array. * * @param data * @return */ public static float[] toFloatArray(byte[] data) { float[] result = new float[data.length / 4]; byte[] tmp = new byte[4]; for (int i = 0; i < result.length; i++) { System.arraycopy(data, i * 4, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
@Override public void setByteArrayRepresentation(byte[] in, int offset, int length) { byte[] tmp = new byte[4]; descriptor = new double[length / 4 - 4]; location = new float[2]; System.arraycopy(in, offset, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, offset + 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }
/** * Convenience method for creating a float array from a byte array. * * @param in * @param offset * @param length * @return */ public static float[] toFloatArray(byte[] in, int offset, int length) { float[] result = new float[length / 4]; byte[] tmp = new byte[4]; for (int i = offset; i < length / 4; i++) { System.arraycopy(in, (i - offset) * 4 + offset, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
@Override public void setByteArrayRepresentation(byte[] in, int offset, int length) { byte[] tmp = new byte[4]; descriptor = new double[length / 4 - 4]; location = new float[2]; System.arraycopy(in, offset, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, offset + 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }
/** * Reads descriptor from a byte array. Much faster than the String based method. * * @param in byte array from corresponding method * @see CEDD#getByteArrayRepresentation */ @Override public void setByteArrayRepresentation(byte[] in) { byte[] tmp = new byte[4]; descriptor = new double[in.length / 4 - 4]; location = new float[2]; System.arraycopy(in, 0, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }
/** * Reads descriptor from a byte array. Much faster than the String based method. * * @param in byte array from corresponding method * @see CEDD#getByteArrayRepresentation */ @Override public void setByteArrayRepresentation(byte[] in) { byte[] tmp = new byte[4]; descriptor = new double[in.length / 4 - 4]; location = new float[2]; System.arraycopy(in, 0, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }
/** * Convenience method for creating a float array from a byte array. * * @param data * @return */ public static float[] toFloatArray(byte[] data) { float[] result = new float[data.length / 4]; byte[] tmp = new byte[4]; for (int i = 0; i < result.length; i++) { System.arraycopy(data, i * 4, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
@Override public void setByteArrayRepresentation(byte[] in, int offset, int length) { byte[] tmp = new byte[4]; descriptor = new double[length / 4 - 4]; location = new float[2]; System.arraycopy(in, offset, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, offset + 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, offset + 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }
/** * Convenience method for creating a float array from a byte array. * * @param in * @param offset * @param length * @return */ public static float[] toFloatArray(byte[] in, int offset, int length) { float[] result = new float[length / 4]; byte[] tmp = new byte[4]; for (int i = offset; i < length / 4; i++) { System.arraycopy(in, (i - offset) * 4 + offset, tmp, 0, 4); result[i] = toFloat(tmp); } return result; }
/** * Reads descriptor from a byte array. Much faster than the String based method. * * @param in byte array from corresponding method * @see net.semanticmetadata.lire.imageanalysis.CEDD#getByteArrayRepresentation */ public void setByteArrayRepresentation(byte[] in) { byte[] tmp = new byte[4]; descriptor = new double[in.length / 4 - 4]; location = new float[2]; System.arraycopy(in, 0, tmp, 0, 4); scale = SerializationUtils.toFloat(tmp); System.arraycopy(in, 4, tmp, 0, 4); orientation = SerializationUtils.toFloat(tmp); System.arraycopy(in, 8, tmp, 0, 4); location[0] = SerializationUtils.toFloat(tmp); System.arraycopy(in, 12, tmp, 0, 4); location[1] = SerializationUtils.toFloat(tmp); for (int i = 0; i < descriptor.length; i++) { System.arraycopy(in, 16 + i * 4, tmp, 0, 4); descriptor[i] = SerializationUtils.toFloat(tmp); } }