本文整理汇总了C#中TransferSyntax类的典型用法代码示例。如果您正苦于以下问题:C# TransferSyntax类的具体用法?C# TransferSyntax怎么用?C# TransferSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransferSyntax类属于命名空间,在下文中一共展示了TransferSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFileMetadata
/// <summary>
/// Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <param name="syntax">the transfer syntax of the DICOM file</param>
/// <returns>elements preceeding and including transfer syntax element</returns>
public static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, ref TransferSyntax syntax)
{
var elements = new List<IDICOMElement>();
syntax = syntax != TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN
? syntax
: TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;
while (dr.StreamPosition < dr.StreamLength)
{
long position = dr.StreamPosition;
if (TagReader.ReadLittleEndian(dr).Group == _metaGroup)
{
dr.StreamPosition = position;
IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
Tag uid = TagHelper.TRANSFER_SYNTAX_UID;
if (el.Tag == uid)
{
syntax = TransferSyntaxHelper.GetSyntax(el);
}
elements.Add(el);
}
else
{
dr.StreamPosition = position;
break;
}
}
return elements;
}
示例2: ReadFileMetadata
/// <summary>
/// Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <param name="syntax">the transfer syntax of the DICOM file</param>
/// <returns>elements preceeding and including transfer syntax element</returns>
private static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, out TransferSyntax syntax)
{
List<IDICOMElement> elements = new List<IDICOMElement>();
syntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;
while (dr.StreamPosition < dr.StreamLength)
{
long position = dr.StreamPosition;
if (TagReader.ReadLittleEndian(dr).Group == _MetaGroup)
{
dr.StreamPosition = position;
IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
if (el.Tag.CompleteID == TagHelper.TRANSFER_SYNTAX_UID.CompleteID)
{
syntax = TransferSyntaxHelper.GetSyntax(el);
}
elements.Add(el);
}
else
{
dr.StreamPosition = position;
break;
}
}
return elements;
}
示例3: LosslessImageTest
public static void LosslessImageTest(TransferSyntax syntax, DicomFile theFile)
{
if (File.Exists(theFile.Filename))
File.Delete(theFile.Filename);
DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());
theFile.ChangeTransferSyntax(syntax);
theFile.Save(DicomWriteOptions.ExplicitLengthSequence);
DicomFile newFile = new DicomFile(theFile.Filename);
newFile.Load(DicomReadOptions.Default);
newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);
List<DicomAttributeComparisonResult> list = new List<DicomAttributeComparisonResult>();
bool result = newFile.DataSet.Equals(saveCopy.DataSet, ref list);
StringBuilder sb = new StringBuilder();
foreach (DicomAttributeComparisonResult compareResult in list)
sb.AppendFormat("Comparison Failure: {0}, ", compareResult.Details);
Assert.IsTrue(result,sb.ToString());
}
示例4: Main
public static int Main(string[] args)
{
string filename = args[0];
string outfilename = args[1];
using( var sfcts = FileChangeTransferSyntax.New() )
{
FileChangeTransferSyntax fcts = sfcts.__ref__();
//SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.RLELossless );
fcts.SetTransferSyntax( ts );
ImageCodec ic = fcts.GetCodec();
RLECodec rle = RLECodec.Cast( ic );
// need to call at least one member func to check not NULL:
long val = rle.GetBufferLength();
System.Console.WriteLine( val ); // use val to remove a warning
fcts.SetInputFileName( filename );
fcts.SetOutputFileName( outfilename );
if( !fcts.Change() )
{
return 1;
}
}
return 0;
}
示例5: SkipItemLittleEndian
public static void SkipItemLittleEndian(DICOMBinaryReader dr, TransferSyntax syntax)
{
int length = LengthReader.ReadLittleEndian(VR.Null, dr.Skip(4));
if (length != -1)
{
dr.Skip(length);
}
else
{
if (syntax == TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN)
{
while (!IsEndOfSequenceItemLittleEndian(dr))
{
dr.StreamPosition -= 8;
DICOMElementReader.SkipElementExplicitLittleEndian(dr);
}
}
else
{
while (!IsEndOfSequenceItemLittleEndian(dr))
{
dr.StreamPosition -= 8;
DICOMElementReader.SkipElementImplicitLittleEndian(dr);
}
}
}
}
示例6: Main
public static int Main(string[] args)
{
string filename = args[0];
string outfilename = args[1];
using( var sfcts = FileChangeTransferSyntax.New() )
{
FileChangeTransferSyntax fcts = sfcts.__ref__();
//SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.JPEG2000 );
fcts.SetTransferSyntax( ts );
ImageCodec ic = fcts.GetCodec();
JPEG2000Codec jpeg2000 = JPEG2000Codec.Cast( ic );
jpeg2000.SetReversible( false );
jpeg2000.SetQuality(0, 55);
fcts.SetInputFileName( filename );
fcts.SetOutputFileName( outfilename );
if( !fcts.Change() )
{
return 1;
}
}
return 0;
}
示例7: ChangeSyntax
public void ChangeSyntax(TransferSyntax syntax)
{
try
{
if (!_dicomFile.TransferSyntax.Encapsulated)
{
// Check if Overlay is embedded in pixels
OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(_dicomFile.DataSet);
for (int i = 0; i < 16; i++)
{
if (overlayIod.HasOverlayPlane(i))
{
OverlayPlane overlay = overlayIod[i];
if (overlay.OverlayData == null)
{
DicomUncompressedPixelData pd = new DicomUncompressedPixelData(_dicomFile);
overlay.ConvertEmbeddedOverlay(pd);
}
}
}
}
else if (syntax.Encapsulated)
{
// Must decompress first.
_dicomFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
}
_dicomFile.ChangeTransferSyntax(syntax);
}
catch (Exception e)
{
Platform.Log(LogLevel.Error, e, "Unexpected exception compressing/decompressing DICOM file");
}
}
示例8: Main
public static int Main(string[] args)
{
string filename = args[0];
string outfilename = args[1];
using( var sfcts = FileChangeTransferSyntax.New() )
{
FileChangeTransferSyntax fcts = sfcts.__ref__();
//SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.JPEGLSNearLossless );
fcts.SetTransferSyntax( ts );
ImageCodec ic = fcts.GetCodec();
JPEGLSCodec jpegls = JPEGLSCodec.Cast( ic );
jpegls.SetLossless( false );
jpegls.SetLossyError( 2 );
fcts.SetInputFileName( filename );
fcts.SetOutputFileName( outfilename );
if( !fcts.Change() )
{
return 1;
}
}
return 0;
}
示例9: DicomCompressCommand
public DicomCompressCommand(DicomMessageBase file, TransferSyntax syntax, IDicomCodec codec, DicomCodecParameters parms)
: base("DICOM Compress Command", true)
{
_file = file;
_syntax = syntax;
_codec = codec;
_parms = parms;
}
示例10: ReadObject
public static DICOMObject ReadObject(byte[] objectBytes, TransferSyntax syntax)
{
List<IDICOMElement> elements;
using (DICOMBinaryReader dr = new DICOMBinaryReader(objectBytes))
{
elements = DICOMElementReader.ReadAllElements(dr, syntax);
}
return new DICOMObject(elements);
}
示例11: Read
/// <summary>
/// Reads the length from a series of bytes in a stream. The number of bytes is automatically determined from
/// VR.
/// </summary>
/// <param name="vr">the value representation of the element</param>
/// <param name="dr">the binary stream with a current position on the length parameter</param>
/// <param name="syntax">the transfer syntax of this element</param>
/// <returns></returns>
public static int Read(VR vr, DICOMBinaryReader dr, TransferSyntax syntax)
{
switch (syntax)
{
case TransferSyntax.EXPLICIT_VR_BIG_ENDIAN:
return ReadBigEndian(vr, dr);
default:
return ReadLittleEndian(vr, dr);
}
}
示例12: DicomPresContext
internal DicomPresContext(byte pcid, SopClass abstractSyntax, TransferSyntax transferSyntax, DicomPresContextResult result) {
_pcid = pcid;
_result = result;
_roles = DicomRoleSelection.Disabled;
_abstract = abstractSyntax;
if (abstractSyntax.Uid.Length == 0)
throw new DicomException("Invalid abstract syntax for presentation context, UID is zero length.");
_transfers = new List<TransferSyntax>();
_transfers.Add(transferSyntax);
}
示例13: ReadObject
public static DICOMObject ReadObject(byte[] objectBytes, TransferSyntax syntax, out long bytesRead)
{
List<IDICOMElement> elements;
using (var dr = new DICOMBinaryReader(objectBytes))
{
elements = DICOMElementReader.ReadAllElements(dr, syntax);
bytesRead = dr.StreamPosition;
}
return new DICOMObject(elements);
}
示例14: ReadIndefiniteLengthLittleEndian
public static int ReadIndefiniteLengthLittleEndian(DICOMBinaryReader dr, TransferSyntax syntax)
{
long startingPos = dr.StreamPosition;
while (!IsEndOfSequenceLittleEndian(dr))
{
dr.StreamPosition -= 8;
SequenceItemReader.SkipItemLittleEndian(dr, syntax);
}
return CalculateLength(dr, startingPos)-8;
}
示例15: ReadLittleEndian
/// <summary>
/// Reads the data from an element encoded in little endian byte order
/// </summary>
/// <param name="lengthToRead">the length of the data</param>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <returns>the data from this element</returns>
public static byte[] ReadLittleEndian(int lengthToRead, DICOMBinaryReader dr, TransferSyntax syntax)
{
if (lengthToRead != -1)
{
return dr.ReadBytes(lengthToRead);
}
int length = SequenceReader.ReadIndefiniteLengthLittleEndian(dr, syntax);
byte[] seqBytes = dr.ReadBytes(length);
dr.Skip(8);
return seqBytes;
}