今天在用DicomFile.Open(Stream s)這個接口時,遇到一個異常:
? ?DicomIoException: Requested 132 bytes past end of fixed length stream.
具體原因我們看下源碼就很清楚:
public bool Require(uint count, ByteSourceCallback callback, object state) {
lock (_lock) {
if ((_stream.Length - _stream.Position) >= count)
return true;
throw new DicomIoException("Requested {0} bytes past end of fixed length stream.", count);
}
}
當時的Stream的Position位于流末尾,即Length-Position等于0, 因此拋出這個異常。
解決辦法很簡單:
首先把Stream定位到DICOM的起始位置。
類似代碼如下:
var stream = new MemoryStream();
? ? ? ? ? using (var f = File.Open(@"1.2.156.112605.75006881735343.1369658682.4.4.1.dcm", FileMode.Open))
? ? ? ? ? {
? ? ? ? ? ? ? f.CopyTo(stream);
? ? ? ? ? }
? ? ? ? ? stream.Seek(0, SeekOrigin.Begin);
? ? ? ? ? var df = Dicom.DicomFile.Open(stream);
- 前言
- HL7 Tools suite
- HL7 Event Type
- HL7 ADT Message Sample
- IHE-PIX 備注
- HL7 V2 分隔符
- 有關HL7 的C# 源碼
- Pix mesa 自動化測試
- hl7 V2中Message Control ID的含義及應用
- hl7消息中和時間有關的字段的格式
- hl7中V2版本的ACK消息的構造
- hl7 v2.X 版本中RSP_K23消息的構造
- HL7及PIX相關的測試工具
- HL7 標準及實現指南 必看的網址
- IHE 官方網址有用資源介紹
- PIX v2版本中Query 失敗時, ERR段的構造
- AspNet WebApi 中應用fo-dicom拋出異常:No codec registered for tranfer syntax:
- DicomIoException: Requested 132 bytes past end of fixed length stream.