首页 > 其他 > 详细

DicomIoException: Requested 132 bytes past end of fixed length stream.

时间:2016-02-29 10:41:59      阅读:226      评论:0      收藏:0      [点我收藏+]
今天在用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, 因此抛出这个异常。


解决的方法非常easy:
首先把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);

DicomIoException: Requested 132 bytes past end of fixed length stream.

原文:http://www.cnblogs.com/bhlsheji/p/5226523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!