@Override public int toInt(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return 0; return bigEndian ? ByteUtils.bytesBE2ushort(val, 0) : ByteUtils.bytesLE2ushort(val, 0); }
@Override public void toggleEndian(byte[] val, int off, int len) { ByteUtils.toggleShortEndian(val, off, len); } }
@Override public double toDouble(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return 0f; return bigEndian ? ByteUtils.bytesBE2double(val, 0) : ByteUtils.bytesLE2double(val, 0); }
@Override public float[] toFloats(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return EMPTY_FLOAT_ARRAY; return bigEndian ? ByteUtils.bytesBE2floats(val) : ByteUtils.bytesLE2floats(val); }
@Override public double[] toDoubles(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return EMPTY_DOUBLE_ARRAY; return bigEndian ? ByteUtils.bytesBE2doubles(val) : ByteUtils.bytesLE2doubles(val); }
public int readHeader() throws IOException { tagpos = pos; readFully(header, 0, 8); tag = ts.bigEndian() ? ByteUtils.bytesBE2tag(header, 0) : ByteUtils .bytesLE2tag(header, 0); if (expectFmiEnd && !TagUtils.isFileMetaInfoElement(tag)) { log.warn("Missing or wrong (0002,0000) Group Length of File Meta Information"); if (tsuid != null) { ts = TransferSyntax.valueOf(tsuid); tag = ts.bigEndian() ? ByteUtils.bytesBE2tag(header, 0) : ByteUtils.bytesLE2tag(header, 0); } else { log vallen = ts.bigEndian() ? ByteUtils.bytesBE2ushort(header, 6) : ByteUtils.bytesLE2ushort(header, 6); if (vr == VR.UN_SIEMENS) { if (log.isInfoEnabled()) { vallen = ts.bigEndian() ? ByteUtils.bytesBE2int(header, 4) : ByteUtils .bytesLE2int(header, 4); return tag;
@Override public float toFloat(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return 0f; return bigEndian ? ByteUtils.bytesBE2float(val, 0) : ByteUtils.bytesLE2float(val, 0); }
@Override public int toInt(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return 0; return bigEndian ? ByteUtils.bytesBE2int(val, 0) : ByteUtils.bytesLE2int(val, 0); }
public static int[] bytesLE2ushorts(byte[] b) { if (b == null) return null; if ((b.length & 0x1) != 0) throw new IllegalArgumentException("byte[" + b.length + "]"); int[] val = new int[b.length >> 1]; for (int i = 0; i < val.length; i++) val[i] = bytesLE2ushort(b, i << 1); return val; }
@Override public double[] toDoubles(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return EMPTY_DOUBLE_ARRAY; return bigEndian ? ByteUtils.bytesBE2floats2doubles(val) : ByteUtils.bytesLE2floats2doubles(val); }
@Override public int[] toInts(byte[] val, boolean bigEndian) { return bigEndian ? ByteUtils.bytesBE2ints(val) : ByteUtils .bytesLE2ints(val); }
public static int bytesBE2tag(byte[] b, int off) { return bytesBE2int(b, off); }
public static float[] bytesBE2floats(byte[] b) { if (b == null) return null; if ((b.length & 0x3) != 0) throw new IllegalArgumentException("byte[" + b.length + "]"); float[] val = new float[b.length >> 2]; for (int i = 0; i < val.length; i++) val[i] = bytesBE2float(b, i << 2); return val; }
public static long[] bytesBE2longs(byte[] b) { if (b == null) return null; if ((b.length & 0x7) != 0) throw new IllegalArgumentException("byte[" + b.length + "]"); long[] val = new long[b.length >> 3]; for (int i = 0; i < val.length; i++) val[i] = bytesBE2long(b, i << 3); return val; }
public static int[] bytesBE2tags(byte[] b) { return bytesBE2ints(b); }
public static double[] bytesBE2doubles(byte[] b) { if (b == null) return null; if ((b.length & 0x7) != 0) throw new IllegalArgumentException("byte[" + b.length + "]"); double[] val = new double[b.length >> 3]; for (int i = 0; i < val.length; i++) val[i] = bytesBE2double(b, i << 3); return val; }
@Override public float toFloat(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return 0f; return bigEndian ? ByteUtils.bytesBE2float(val, 0) : ByteUtils.bytesLE2float(val, 0); }
? ByteUtils.bytesBE2int(val, i) : ByteUtils.bytesLE2int(val, i)) & 0xffffffffL); int sl = s.length(); s.getChars(0, sl, cbuf, clen);
/** Gets a pixel value from the given field - the field can be a regular integer * or it can be ob data. * @param ds * @param tag * @return */ public static Integer getIntPixelValue(DicomObject ds, int tag, boolean signed, int stored) { DicomElement de = ds.get(tag); if( de==null ) return null; VR vr = de.vr(); if( vr==VR.OB || vr==VR.OW ) { int ret = ByteUtils.bytesLE2ushort(de.getBytes(),0); if( signed ) { if( (ret & (1 << (stored-1))) !=0 ) { int andmask = (1 << stored) - 1; int ormask = ~andmask; ret |= ormask; } } return ret; } return de.getInt(true); }
@Override public float[] toFloats(byte[] val, boolean bigEndian) { if (val == null || val.length == 0) return EMPTY_FLOAT_ARRAY; return bigEndian ? ByteUtils.bytesBE2floats(val) : ByteUtils.bytesLE2floats(val); }