vr = vrs[i]; val = values[i]; len = explicitVR ? vr.headerLength() : 8; if (val instanceof Value) len += ((Value) val).calcLength(encOpts, explicitVR, vr);
public void writeHeader(int tag, VR vr, int len) throws IOException { byte[] b = buf; ByteUtils.tagToBytes(tag, b, 0, bigEndian); int headerLen; if (!TagUtils.isItem(tag) && explicitVR) { ByteUtils.shortToBytesBE(vr.code(), b, 4); if ((headerLen = vr.headerLength()) == 8) { ByteUtils.shortToBytes(len, b, 6, bigEndian); } else { b[6] = b[7] = 0; ByteUtils.intToBytes(len, b, 8, bigEndian); } } else { ByteUtils.intToBytes(len, b, 4, bigEndian); headerLen = 8; } out.write(b, 0, headerLen); }
public void readHeader() throws IOException { byte[] buf = buffer; tagPos = pos; readFully(buf, 0, 8); encodedVR = 0; switch(tag = ByteUtils.bytesToTag(buf, 0, bigEndian)) { case Tag.Item: case Tag.ItemDelimitationItem: case Tag.SequenceDelimitationItem: vr = null; break; default: if (explicitVR) { vr = VR.valueOf(encodedVR = ByteUtils.bytesToVR(buf, 4)); if (vr.headerLength() == 8) { length = ByteUtils.bytesToUShort(buf, 6, bigEndian); return; } readFully(buf, 4, 4); } else { vr = VR.UN; } } length = ByteUtils.bytesToInt(buf, 4, bigEndian); }