@Override public void writeTo(DicomOutputStream out, VR vr) throws IOException { for (Object frag : this) out.writeAttribute(Tag.Item, vr, frag, null); }
public void writeAttribute(int tag, VR vr, Object value, SpecificCharacterSet cs) throws IOException { if (value instanceof Value) writeAttribute(tag, vr, (Value) value); else writeAttribute(tag, vr, (value instanceof byte[]) ? (byte[]) value : vr.toBytes(value, cs)); }
private void convert(File infile, File outfile) throws IOException { long fileLength = infile.length(); if (fileLength > MAX_FILE_SIZE) throw new IllegalArgumentException(MessageFormat.format(rb.getString("file-too-large"), infile)); try (DicomOutputStream dos = new DicomOutputStream(outfile)) { dos.writeDataset(metadata.createFileMetaInformation(UID.ExplicitVRLittleEndian), metadata); dos.writeAttribute(Tag.EncapsulatedDocument, VR.OB, Files.readAllBytes(infile.toPath())); } System.out.println(MessageFormat.format(rb.getString("converted"), infile, outfile)); }
private void convert(File infile, File outfile) throws IOException { long fileLength = infile.length(); if (fileLength > MAX_FILE_SIZE) throw new IllegalArgumentException(MessageFormat.format(rb.getString("file-too-large"), infile)); try (DicomOutputStream dos = new DicomOutputStream(outfile)) { dos.writeDataset(metadata.createFileMetaInformation(UID.ExplicitVRLittleEndian), metadata); dos.writeAttribute(Tag.EncapsulatedDocument, VR.OB, Files.readAllBytes(infile.toPath())); } System.out.println(MessageFormat.format(rb.getString("converted"), infile, outfile)); }
private void writeTo(DicomOutputStream out, SpecificCharacterSet cs, int start, int end, int groupLengthIndex) throws IOException { boolean groupLength = groupLengths != null; int groupLengthTag = -1; for (int i = start; i < end; i++) { int tag = tags[i]; if (groupLength) { int tmp = TagUtils.groupLengthTagOf(tag); if (groupLengthTag != tmp) { groupLengthTag = tmp; out.writeGroupLength(groupLengthTag, groupLengths[groupLengthIndex++]); } } out.writeAttribute(tag, vrs[i], values[i], cs); } }