public final void setTransferSyntax(String tsuid) { setTransferSyntax(TransferSyntax.valueOf(tsuid)); }
dos.setTransferSyntax(tsuid); TranscoderInputHandler h = new TranscoderInputHandler(dos, transcoderBufferSize);
/** * Write a DICOM dataset to the output stream. * * @param attrs * A DicomObject containing the attributes to write. * @param transferSyntax * A TransferSyntax object representing the transfer syntax of * the file. * @throws IOException */ public void writeDataset(DicomObject attrs, TransferSyntax transferSyntax) throws IOException { setTransferSyntax(transferSyntax); this.ts = transferSyntax; writeElements(attrs.datasetIterator(), includeGroupLength, createItemInfo(attrs)); if (autoFinish) { finish(); } }
/** * Write a DICOM dataset to the output stream. This one is needed to handle * a case where group 2 elements are within sequence items. * * @param attrs * A DicomObject containing the attributes to write. * @param transferSyntax * A TransferSyntax object representing the transfer syntax of * the file. * @throws IOException */ public void writeDicomObject(DicomObject attrs, TransferSyntax transferSyntax) throws IOException { setTransferSyntax(transferSyntax); this.ts = transferSyntax; writeElements(attrs.iterator(), includeGroupLength, createItemInfo(attrs)); if (autoFinish) { finish(); } }
try { DicomOutputStream dos = new DicomOutputStream(out); dos.setTransferSyntax(tsuid); TranscoderInputHandler h = new TranscoderInputHandler(dos, transcoderBufferSize);
private void transcodeAttribute(DicomInputStream in) throws IOException { final int tag = in.tag(); final VR vr = in.vr(); final int vallen = in.valueLength(); final DicomObject attrs = in.getDicomObject(); if (vallen == -1 || vr == VR.SQ) { out.writeHeader(tag, vr, -1); TransferSyntax prevTS = out.getTransferSyntax(); if (vr == VR.UN) { out.setTransferSyntax(TransferSyntax.ImplicitVRLittleEndian); } in.readValue(in); attrs.remove(tag); out.writeHeader(Tag.SequenceDelimitationItem, null, 0); out.setTransferSyntax(prevTS); } else if (!TagUtils.isGroupLengthElement(tag)) { out.writeHeader(tag, vr, vallen); if (tag == Tag.SpecificCharacterSet || TagUtils.isPrivateCreatorDataElement(tag)) { byte[] val = in.readBytes(vallen); boolean bigEndian = in.getTransferSyntax().bigEndian(); attrs.putBytes(tag, vr, val, bigEndian); out.write(val); } else { transcodeValue(in, vr); } } }