Tabnine Logo
DicomOutputStream
Code IndexAdd Tabnine to your IDE (free)

How to use
DicomOutputStream
in
org.dcm4che2.io

Best Java code snippets using org.dcm4che2.io.DicomOutputStream (Showing top 20 results out of 315)

origin: dcm4che/dcm4che-core

public DicomDirWriter(File file, FileSetInformation fileSetInfo)
throws IOException {
super(new RandomAccessFile(file, "rw"), fileSetInfo);
this.file = file;
// ensure fileSetInfo represents empty file-set 
fileSetInfo.setOffsetFirstRootRecord(0);
fileSetInfo.setOffsetLastRootRecord(0);
raf.setLength(0);
out = new DicomOutputStream(raf);
out.setExplicitSequenceLength(true);
out.setExplicitItemLength(true);
out.writeDicomFile(fileSetInfo.getDicomObject());
out.writeHeader(Tag.DirectoryRecordSequence, VR.SQ, 0);
this.firstRecordPos = (int) out.getStreamPosition();
this.recordSeqLen = 0;
}
origin: dcm4che/dcm4che-net

public void writeTo(PDVOutputStream out, String tsuid) throws IOException
{
  DicomOutputStream dos = new DicomOutputStream(out);
  dos.writeDataset(data, TransferSyntax.valueOf(tsuid));
}

origin: dcm4che/dcm4che-core

/**
 * 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();
  }
}
origin: dcm4che/dcm4che-core

private void writeObject(ObjectOutputStream s)
    throws IOException {
  s.defaultWriteObject();
  DicomOutputStream dos = new DicomOutputStream((OutputStream) s);
  dos.serializeDicomObject(attrs);
}
origin: dcm4che/dcm4che-imageio

/**
 * Write the given image as a byte array to the sequence.
 */
public void writeBytesToSequence(byte[] data, ImageWriteParam param)
    throws IOException {
  if (encapsulated) {
    dos.writeHeader(Tag.Item, null, (data.length+1) & ~1);
  }
  dos.write(data);
  if ((data.length & 1) != 0)
    dos.write(0);
  // The flush allows any memory buffer to be cleared.
  dos.flush();
  ((ImageOutputStream) output).flush();
}
origin: dcm4che/dcm4che-core

public void writeFileMetaInformation(DicomObject attrs) throws IOException {
  if (preamble != null) {
    write(preamble, 0, PREAMBLE_LENGTH);
    write('D');
    write('I');
    write('C');
    write('M');
  }
  this.ts = TransferSyntax.ExplicitVRLittleEndian;
  writeElements(attrs.fileMetaInfoIterator(), true, new ItemInfo(attrs
      .fileMetaInfoIterator(), true));
}
origin: dcm4che/dcm4che-imageio

DicomObject dobj = dmeta.getDicomObject();
Object output = getOutput();
dos = new DicomOutputStream((ImageOutputStream) output);
dos.setAutoFinish(false);
if( dmeta.isFileMetaInfoIncluded() ) {
  dos.writeDicomFile(dobj);
} else {
  dos.writeDataset(dobj, dobj.getString(Tag.TransferSyntaxUID));
  dos.writeHeader(Tag.PixelData, VR.OB, -1);
  dos.writeHeader(Tag.Item, null, 0);
} else {
  int frames = dobj.getInt(Tag.NumberOfFrames, 1);
    dos.writeHeader(Tag.PixelData, vr, pixelDataLength);
dos.flush();
((ImageOutputStream) output).flush();
origin: bioinformatics-ua/dicoogle

   dis.close();
 DicomOutputStream dos = new DicomOutputStream(out);
 attrs.putString(Tag.RetrieveURI, VR.UT, info.f.toURI().toString());
 dos.writeDataset(attrs, tsuid);
} else {
 DicomInputStream dis = null;
   DicomOutputStream dos = new DicomOutputStream(out);
   dos.setTransferSyntax(tsuid);
   TranscoderInputHandler h = new TranscoderInputHandler(dos,
       transcoderBufferSize);
origin: dcm4che/dcm4che-core

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);
    }
  }
 }
origin: dcm4che/dcm4che-core

public DicomDirWriter(File file) throws IOException {
super(new RandomAccessFile(checkExists(file), "rw"));
this.file = file;
offsetFirstRootRecord(filesetInfo.getOffsetFirstRootRecord());
offsetLastRootRecord(filesetInfo.getOffsetLastRootRecord());
this.firstRecordPos = in.getStreamPosition();
this.recordSeqLen = in.valueLength();
out = new DicomOutputStream(raf);
out.setExplicitSequenceLength(recordSeqLen != -1);
out.setExplicitItemLength(recordSeqLen != -1);
if (filesetInfo.isEmpty()) {
  this.recordSeqLen = 0;
}
}
origin: dcm4che/dcm4che-core

    gggg0 = gggg;
    assert itemInfo != null;
    writeGroupLength(gggg, itemInfo.grlen[++gri]);
writeHeader(a.tag(), vr, len);
a.bigEndian(ts.bigEndian());
if (a.hasItems()) {
          .removeFirst()
          : null;
      writeItem(item, childItemInfo);
    for (int i = 0, n = a.countItems(); i < n; i++) {
      byte[] val = a.getFragment(i);
      writeHeader(Tag.Item, null, (val.length + 1) & ~1);
      write(val);
      if ((val.length & 1) != 0)
        write(0);
  write(val);
  if ((val.length & 1) != 0)
    write(vr.padding());
  writeHeader(Tag.SequenceDelimitationItem, null, 0);
origin: dcm4che/dcm4che-net

DicomOutputStream cmdout = new DicomOutputStream(this);
cmdout.writeCommand(cmd);
cmdout.close();
if (dataWriter != null)
origin: dcm4che/dcm4che-imageio

public void writePostPixeldata(DicomObject dobj, String transferSyntax) throws IOException{        
  dos.writeDataset(dobj, transferSyntax);
  
  dos.flush();
  finishStream();
}
origin: dcm4che/dcm4che-core

/**
 * Write a DICOM object to the output stream using the specified
 * <code>DicomObject</code> to obtain the transfer syntax UID and other
 * attributes.
 * 
 * @param attrs
 *            The <code>DicomObject</code> containing the DICOM tags to
 *            write into the file.
 * @throws IOException
 */
public void writeDicomFile(DicomObject attrs) throws IOException {
  String tsuid = attrs.getString(Tag.TransferSyntaxUID);
  if (tsuid == null)
    throw new IllegalArgumentException(
        "Missing (0002,0010) Transfer Syntax UID");
  writeFileMetaInformation(attrs);
  writeDataset(attrs, tsuid);
}
origin: dcm4che/dcm4che-core

private void writeGroupLength(int tag, int length) throws IOException {
  writeHeader(tag, VR.UL, 4);
  write(VR.UL.toBytes(length, ts.bigEndian()), 0, 4);
}
origin: dcm4che/dcm4che-core

/**
 * Write a DICOM dataset to the output stream.
 * 
 * @param attrs
 *            A DicomObject containing the attributes to write.
 * @param tsuid
 *            A String containing the transfer syntax UID of the file.
 * @throws IOException
 */
public void writeDataset(DicomObject attrs, String tsuid)
    throws IOException {
  writeDataset(attrs, TransferSyntax.valueOf(tsuid));
}
origin: dcm4che/dcm4che-core

private void transcodeValue(DicomInputStream in, VR vr)
throws IOException
{
  boolean toggleEndian = out.getTransferSyntax().bigEndian()
             != in.getTransferSyntax().bigEndian();
  int remaining = in.valueLength();
  while (remaining > 0)
  {
    int len = Math.min(remaining, buf.length);
    in.readFully(buf, 0, len);
    if (toggleEndian)
      vr.toggleEndian(buf, 0, len);
    out.write(buf, 0, len);
    remaining -= len;
  }
}
origin: dcm4che/dcm4che-core

/**
 * Only for internal use by {@link org.dcm4che2.data.DicomObjectSerializer}.
 */
public void serializeDicomObject(DicomObject attrs) throws IOException {
  this.ts = TransferSyntax.ExplicitVRLittleEndian;
  writeElements(attrs.iterator(), false, null);
  writeHeader(Tag.ItemDelimitationItem, null, 0);
}
origin: dcm4che/dcm4che-core

public synchronized void rollback() throws IOException {
filesetInfo.setOffsetFirstRootRecord(offsetFirstRootRecord());
filesetInfo.setOffsetLastRootRecord(offsetLastRootRecord());
cache.clear();
  cachedParentRecord = null;
  cachedLastChildRecord = null;
dirtyRecords.clear();
if (rollbackLen != -1) {
  recordSeqLen = rollbackLen - firstRecordPos;
  raf.seek(rollbackLen);
  if (!out.isExplicitSequenceLength() && !isEmpty()) {
  out.writeHeader(Tag.SequenceDelimitationItem, null, 0);
  }
  raf.setLength(raf.getFilePointer());
  rollbackLen = -1;
  raf.seek(firstRecordPos - 14);
  raf.writeShort(FileSetInformation.NO_KNOWN_INCONSISTENCIES);
  filesetInfo.setFileSetConsistencyFlag(
    FileSetInformation.NO_KNOWN_INCONSISTENCIES);
}
}
origin: dcm4che/dcm4che-imageio

public void endWriteSequence(boolean finish) throws IOException {
  if (encapsulated){
    dos.writeHeader(Tag.SequenceDelimitationItem, null, 0);    		
  }
  if (finish) {
    finishStream();
  }
}
org.dcm4che2.ioDicomOutputStream

Most used methods

  • <init>
  • writeDataset
    Write a DICOM dataset to the output stream.
  • finish
    Finishes writing compressed data to the output stream without closing the underlying stream. Use thi
  • getTransferSyntax
  • setTransferSyntax
  • write
  • writeDicomFile
    Write a DICOM object to the output stream using the specifiedDicomObject to obtain the transfer synt
  • writeHeader
  • close
  • createItemInfo
  • flush
  • getStreamPosition
  • flush,
  • getStreamPosition,
  • isExplicitItemLength,
  • isExplicitItemLengthIfZero,
  • isExplicitSequenceLength,
  • isExplicitSequenceLengthIfZero,
  • isIncludeGroupLength,
  • needItemInfo,
  • serializeDicomObject,
  • setAutoFinish

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now