public byte[] getBytes() { return e.getBytes(); }
private static byte[] writeInlineBinary(DicomElement elem) { return elem.getBytes(); }
public static boolean isStudyRoot(DicomObject rsp) { DicomElement elem = rsp.get(Integer.parseInt("00000002", 16)); String affectedSOP = new String(elem.getBytes()); if (affectedSOP.equals("1.2.840.10008.5.1.4.1.2.1.1")) { return true; } return false; }
public static boolean isPatientRoot(DicomObject rsp) { DicomElement elem = rsp.get(Integer.parseInt("00000002", 16)); String affectedSOP = new String(elem.getBytes()); if (affectedSOP.equals("1.2.840.10008.5.1.4.1.2.2.1")) { return true; } return false; }
private byte[] toBytes(DicomElement a, boolean bigEndian) { return a == null ? null : a.bigEndian(bigEndian).getBytes(); }
String affectedSOP = new String(elem.getBytes());
String levelStr = new String(elem.getBytes());
public DicomElement get(int tag, VR vr) { DicomElement e = get(tag); if (e == null || e.vr() == vr) { return e; } if (e.vr() != VR.UN) { throw new UnsupportedOperationException("Update VR from " + e.vr() + " to " + vr + " not supported"); } if (vr != VR.SQ) { return putBytes(tag, vr, e.getBytes()); } DicomElement sq = putSequence(tag); if (!e.isEmpty()) { try { byte[] b = e.getBytes(); DicomInputStream in = new DicomInputStream( new ByteArrayInputStream(b), UID.ImplicitVRLittleEndian); in.readItems(sq, b.length); } catch (IOException e1) { throw new RuntimeException("Failed to parse value of " + e + " as sequence of items", e1); } } return sq; } }
/** 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); }
private void writeElement(DicomObject attrs, DicomElement a) throws SAXException, IOException { VR vr = a.vr(); final int tag = a.tag(); if (file != null) file = new File(file, StringUtils.intToHex(tag)); String fpath = fpath(tag, vr, a.length()); startAttributeElement(tag, vr, a.length(), fpath, attrs); if (a.hasItems()) { for (int i = 0, n = a.countItems(); i < n; ++i) { writeItem(a, i); } } else { if (fpath != null) { writeToFile(a.getBytes()); } else { vr.formatXMLValue(a.getBytes(), a.bigEndian(), attrs.getSpecificCharacterSet(), cbuf, ch); } } endAttributeElement(); if (file != null) file = file.getParentFile(); }
String add = ""; if (e != null) { add = new String(e.getBytes());
byte[] val = a.getBytes(); write(val); if ((val.length & 1) != 0)
dest.putBytes(destTag, vr, attr.getBytes(), attr.bigEndian());